@mintlify/common 1.0.421 → 1.0.423
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.
- package/dist/mdx/plugins/remark/remarkExtractChangelogFilters.js +3 -12
- package/dist/mdx/plugins/remark/remarkMdxRemoveUnknownJsx/index.js +2 -1
- package/dist/mdx/utils.d.ts +3 -1
- package/dist/mdx/utils.js +34 -0
- package/dist/rss/index.d.ts +14 -2
- package/dist/rss/index.js +45 -13
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/rss.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { getArrayExpressionStringProperties } from '../../utils.js';
|
|
1
2
|
export function remarkExtractChangelogFilters(mdxExtracts) {
|
|
2
3
|
return (tree) => {
|
|
3
|
-
var _a, _b;
|
|
4
4
|
const tagCounts = new Map();
|
|
5
5
|
for (let nodeIndex = 0; nodeIndex < tree.children.length; nodeIndex++) {
|
|
6
6
|
const node = tree.children[nodeIndex];
|
|
@@ -15,17 +15,8 @@ export function remarkExtractChangelogFilters(mdxExtracts) {
|
|
|
15
15
|
try {
|
|
16
16
|
tags = JSON.parse(tagsAttribute.value.value);
|
|
17
17
|
}
|
|
18
|
-
catch (
|
|
19
|
-
|
|
20
|
-
const body = tagsAttribute.value.data.estree.body[0];
|
|
21
|
-
if ((body === null || body === void 0 ? void 0 : body.type) === 'ExpressionStatement' && body.expression.type === 'ArrayExpression') {
|
|
22
|
-
tags = body.expression.elements
|
|
23
|
-
.map((element) => {
|
|
24
|
-
return (element === null || element === void 0 ? void 0 : element.type) === 'Literal' ? element.value : null;
|
|
25
|
-
})
|
|
26
|
-
.filter(Boolean);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
18
|
+
catch (_a) {
|
|
19
|
+
tags = getArrayExpressionStringProperties(tagsAttribute);
|
|
29
20
|
}
|
|
30
21
|
if (!Array.isArray(tags)) {
|
|
31
22
|
continue;
|
|
@@ -6,7 +6,8 @@ export const remarkMdxRemoveUnknownJsx = (allowedComponents) => (tree) => {
|
|
|
6
6
|
return map(tree, (node) => {
|
|
7
7
|
if (isMdxJsxFlowElementHast(node)) {
|
|
8
8
|
if (node.name &&
|
|
9
|
-
|
|
9
|
+
Array.isArray(allowedComponents) &&
|
|
10
|
+
!allowedComponents.includes(node.name) &&
|
|
10
11
|
!exportedComponentNames.includes(node.name)) {
|
|
11
12
|
return createCommentNode(node.name);
|
|
12
13
|
}
|
package/dist/mdx/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ImportDeclaration, ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, Program } from 'estree-jsx';
|
|
2
|
-
import { MdxFlowExpression, MdxjsEsm, MdxTextExpression } from 'mdast-util-mdx';
|
|
2
|
+
import { MdxFlowExpression, MdxjsEsm, MdxJsxAttribute, MdxJsxExpressionAttribute, MdxTextExpression } from 'mdast-util-mdx';
|
|
3
3
|
import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
|
4
4
|
import type { Node } from 'unist';
|
|
5
5
|
import type { MdxNodeBodyChildType } from '../types/mdx/index.js';
|
|
@@ -14,3 +14,5 @@ export declare const isExport: (type: string) => boolean;
|
|
|
14
14
|
export declare const isExportNode: (bodyChild: MdxNodeBodyChildType) => bodyChild is ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration;
|
|
15
15
|
export declare const isMdxJsxFlowElement: (node: Node) => node is MdxJsxFlowElement;
|
|
16
16
|
export declare const createUniqueVariableName: (variableName: string, id: number) => string;
|
|
17
|
+
export declare const getObjectExpressionStringProperty: (key: string, attribute: MdxJsxAttribute | MdxJsxExpressionAttribute | undefined) => string | undefined;
|
|
18
|
+
export declare const getArrayExpressionStringProperties: (attribute: MdxJsxAttribute | MdxJsxExpressionAttribute | undefined) => string[];
|
package/dist/mdx/utils.js
CHANGED
|
@@ -12,3 +12,37 @@ export const isExport = (type) => [
|
|
|
12
12
|
export const isExportNode = (bodyChild) => isExport(bodyChild.type);
|
|
13
13
|
export const isMdxJsxFlowElement = (node) => node.type === 'mdxJsxFlowElement';
|
|
14
14
|
export const createUniqueVariableName = (variableName, id) => `${variableName}_${id}`;
|
|
15
|
+
export const getObjectExpressionStringProperty = (key, attribute) => {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
if (!attribute || !attribute.value || typeof attribute.value !== 'object') {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
if (((_b = (_a = attribute.value.data) === null || _a === void 0 ? void 0 : _a.estree) === null || _b === void 0 ? void 0 : _b.body.length) === 1) {
|
|
21
|
+
const body = attribute.value.data.estree.body[0];
|
|
22
|
+
if ((body === null || body === void 0 ? void 0 : body.type) === 'ExpressionStatement' && body.expression.type === 'ObjectExpression') {
|
|
23
|
+
const properties = body.expression.properties;
|
|
24
|
+
const property = properties.find((prop) => prop.type === 'Property' && prop.key.type === 'Identifier' && prop.key.name === key);
|
|
25
|
+
if (property && property.type === 'Property' && property.value.type === 'Literal') {
|
|
26
|
+
return (_c = property.value.value) === null || _c === void 0 ? void 0 : _c.toString();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export const getArrayExpressionStringProperties = (attribute) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const collection = [];
|
|
34
|
+
if (!attribute || !attribute.value || typeof attribute.value !== 'object') {
|
|
35
|
+
return collection;
|
|
36
|
+
}
|
|
37
|
+
if (((_b = (_a = attribute.value.data) === null || _a === void 0 ? void 0 : _a.estree) === null || _b === void 0 ? void 0 : _b.body.length) === 1) {
|
|
38
|
+
const body = attribute.value.data.estree.body[0];
|
|
39
|
+
if ((body === null || body === void 0 ? void 0 : body.type) === 'ExpressionStatement' && body.expression.type === 'ArrayExpression') {
|
|
40
|
+
body.expression.elements.map((element) => {
|
|
41
|
+
if ((element === null || element === void 0 ? void 0 : element.type) === 'Literal' && typeof element.value === 'string') {
|
|
42
|
+
collection.push(element.value);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return collection;
|
|
48
|
+
};
|
package/dist/rss/index.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import type { FrontmatterContent, Root, RootContent } from 'mdast';
|
|
2
2
|
import { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
|
3
|
+
export declare const UPDATE_MAX = 15;
|
|
4
|
+
export type UpdateMDXComponent = MdxJsxFlowElement;
|
|
3
5
|
export declare const isFrontmatter: (node: RootContent | undefined) => node is FrontmatterContent;
|
|
4
|
-
export declare const isUpdate: (node: RootContent | undefined) => node is
|
|
6
|
+
export declare const isUpdate: (node: RootContent | undefined) => node is UpdateMDXComponent;
|
|
5
7
|
export declare const containsUpdates: (tree: Root) => boolean;
|
|
6
|
-
export declare const getTags: (node:
|
|
8
|
+
export declare const getTags: (node: UpdateMDXComponent) => string[] | undefined;
|
|
9
|
+
export declare const getRssPropsData: (updateComponent: UpdateMDXComponent) => {
|
|
10
|
+
rssTitle: string | undefined;
|
|
11
|
+
rssDescription: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare const getUpdateTitle: (updateComponent: UpdateMDXComponent) => string | undefined;
|
|
14
|
+
export declare const getUpdateDescription: (updateComponent: UpdateMDXComponent) => string | undefined;
|
|
15
|
+
export declare const compareUpdates: ({ newTree, previousTree, }: {
|
|
16
|
+
newTree: Root;
|
|
17
|
+
previousTree: Root;
|
|
18
|
+
}) => UpdateMDXComponent[];
|
package/dist/rss/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getArrayExpressionStringProperties, getObjectExpressionStringProperty, } from '../mdx/utils.js';
|
|
2
|
+
export const UPDATE_MAX = 15;
|
|
1
3
|
export const isFrontmatter = (node) => {
|
|
2
4
|
return (node === null || node === void 0 ? void 0 : node.type) === 'yaml';
|
|
3
5
|
};
|
|
@@ -8,7 +10,6 @@ export const containsUpdates = (tree) => {
|
|
|
8
10
|
return tree.children.some((child) => isUpdate(child));
|
|
9
11
|
};
|
|
10
12
|
export const getTags = (node) => {
|
|
11
|
-
var _a, _b;
|
|
12
13
|
let tags = [];
|
|
13
14
|
const tagsAttribute = node.attributes.find((attr) => 'name' in attr && attr.name === 'tags');
|
|
14
15
|
if (!tagsAttribute || !tagsAttribute.value || typeof tagsAttribute.value !== 'object') {
|
|
@@ -17,17 +18,48 @@ export const getTags = (node) => {
|
|
|
17
18
|
try {
|
|
18
19
|
tags = JSON.parse(tagsAttribute.value.value);
|
|
19
20
|
}
|
|
20
|
-
catch (
|
|
21
|
-
|
|
22
|
-
const body = tagsAttribute.value.data.estree.body[0];
|
|
23
|
-
if ((body === null || body === void 0 ? void 0 : body.type) === 'ExpressionStatement' && body.expression.type === 'ArrayExpression') {
|
|
24
|
-
body.expression.elements.map((element) => {
|
|
25
|
-
if ((element === null || element === void 0 ? void 0 : element.type) === 'Literal' && typeof element.value === 'string') {
|
|
26
|
-
tags.push(element.value);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
tags = getArrayExpressionStringProperties(tagsAttribute);
|
|
31
23
|
}
|
|
32
|
-
|
|
24
|
+
if (tags.length > 0) {
|
|
25
|
+
return tags;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
};
|
|
29
|
+
export const getRssPropsData = (updateComponent) => {
|
|
30
|
+
const attributes = updateComponent.attributes;
|
|
31
|
+
const rssData = attributes.find((attribute) => attribute.type === 'mdxJsxAttribute' && attribute.name === 'rss');
|
|
32
|
+
const title = getObjectExpressionStringProperty('title', rssData);
|
|
33
|
+
const description = getObjectExpressionStringProperty('description', rssData);
|
|
34
|
+
return { rssTitle: title, rssDescription: description };
|
|
35
|
+
};
|
|
36
|
+
export const getUpdateTitle = (updateComponent) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const attributes = updateComponent.attributes;
|
|
39
|
+
const label = (_a = attributes.find((attribute) => attribute.type === 'mdxJsxAttribute' && attribute.name === 'label')) === null || _a === void 0 ? void 0 : _a.value;
|
|
40
|
+
if (label) {
|
|
41
|
+
return label.toString();
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
};
|
|
45
|
+
export const getUpdateDescription = (updateComponent) => {
|
|
46
|
+
var _a;
|
|
47
|
+
const attributes = updateComponent.attributes;
|
|
48
|
+
const descriptionAttribute = (_a = attributes.find((attribute) => attribute.type === 'mdxJsxAttribute' && attribute.name === 'description')) === null || _a === void 0 ? void 0 : _a.value;
|
|
49
|
+
if (descriptionAttribute) {
|
|
50
|
+
return descriptionAttribute.toString();
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
};
|
|
54
|
+
export const compareUpdates = ({ newTree, previousTree, }) => {
|
|
55
|
+
const newUpdateComponents = newTree.children.filter((child) => isUpdate(child));
|
|
56
|
+
const previousUpdateComponents = previousTree.children
|
|
57
|
+
.filter((child) => isUpdate(child))
|
|
58
|
+
.map(getUpdateTitle);
|
|
59
|
+
const previousUpdateComponentsSet = new Set(previousUpdateComponents);
|
|
60
|
+
const newUpdates = newUpdateComponents.filter((component) => {
|
|
61
|
+
const title = getUpdateTitle(component);
|
|
62
|
+
return !previousUpdateComponentsSet.has(title);
|
|
63
|
+
});
|
|
64
|
+
return newUpdates;
|
|
33
65
|
};
|