@mintlify/common 1.0.1291 → 1.0.1293
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/remarkVisibilityForMarkdown.d.ts +5 -1
- package/dist/mdx/plugins/remark/remarkVisibilityForMarkdown.js +29 -3
- package/dist/mdx/plugins/remark/unfoldComponentsForMarkdown.d.ts +2 -0
- package/dist/mdx/plugins/remark/unfoldComponentsForMarkdown.js +1 -1
- package/dist/mdx/remark.d.ts +3 -1
- package/dist/mdx/remark.js +15 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -34,4 +34,8 @@ export declare function resolveVisibilityFor(node: MdxJsxElement, scope?: Static
|
|
|
34
34
|
export declare function isHiddenFromHumans(resolution: VisibilityResolution): boolean;
|
|
35
35
|
export declare function isHiddenFromAgents(resolution: VisibilityResolution): boolean;
|
|
36
36
|
export declare function toVisibilityAuthRule(resolution: VisibilityResolution): VisibilityAuthRule | undefined;
|
|
37
|
-
export
|
|
37
|
+
export type RemarkVisibilityForMarkdownOptions = {
|
|
38
|
+
/** `docs.json` variation labels by id, so each `Variation` is titled the way readers see it. */
|
|
39
|
+
variationLabels?: Readonly<Record<string, string>>;
|
|
40
|
+
};
|
|
41
|
+
export declare const remarkVisibilityForMarkdown: ({ variationLabels }?: RemarkVisibilityForMarkdownOptions) => (tree: Root) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getAST, stringifyTree } from '../../remark-core.js';
|
|
2
2
|
import { BLOCK_LINK_LABEL } from './firstPartyMarkdownComponents.js';
|
|
3
3
|
import { evaluateStatic } from './staticEvaluator.js';
|
|
4
|
-
import { chargeUnfoldBudget, chargeUnfoldCall, collectMarkdownComponentContext, collectUsageProps, containsJsx, createUnfoldBudget, definitionGatesContent, DROP_ELEMENTS, FORM_CONTROL_ELEMENTS, dropPairedDarkOnly, escapeInterpolatedText, HEADING_ELEMENTS, isPresentationalAttribute, UNWRAP_BLOCK_ELEMENTS, UNWRAP_INLINE_ELEMENTS, escapeLinkLabel, extractProgramExpression, markdownLinkDestination, MAX_UNFOLD_DEPTH, GFM_ALERT_PATTERN, HEADLINE_ATTRIBUTES, KEEP_TAG_COMPONENTS, materializeComponent, serializeExpressionJsx, } from './unfoldComponentsForMarkdown.js';
|
|
4
|
+
import { chargeUnfoldBudget, chargeUnfoldCall, collectMarkdownComponentContext, collectUsageProps, containsJsx, createUnfoldBudget, definitionGatesContent, DROP_ELEMENTS, FORM_CONTROL_ELEMENTS, dropPairedDarkOnly, escapeInterpolatedText, HEADING_ELEMENTS, isPresentationalAttribute, UNWRAP_BLOCK_ELEMENTS, UNWRAP_INLINE_ELEMENTS, escapeLinkLabel, extractProgramExpression, FAILED_SPREAD, markdownLinkDestination, MAX_UNFOLD_DEPTH, GFM_ALERT_PATTERN, HEADLINE_ATTRIBUTES, KEEP_TAG_COMPONENTS, materializeComponent, serializeExpressionJsx, } from './unfoldComponentsForMarkdown.js';
|
|
5
5
|
import { toVisibilityGroups, toVisibilityGroupsRule, } from './visibility-auth-rule.js';
|
|
6
6
|
export function isVisibilityElement(node) {
|
|
7
7
|
return ((node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') &&
|
|
@@ -655,12 +655,38 @@ function unfoldComponentElement(node, name, ctx) {
|
|
|
655
655
|
var _a;
|
|
656
656
|
if (name === 'Visibility')
|
|
657
657
|
return undefined;
|
|
658
|
+
if (name === 'Variation' && !ctx.defs.has(name))
|
|
659
|
+
return unfoldVariation(node, ctx);
|
|
658
660
|
const baseName = name.split('.')[0];
|
|
659
661
|
if (baseName === undefined || !/^[A-Z]/.test(baseName))
|
|
660
662
|
return undefined;
|
|
661
663
|
const element = name === 'Steps' ? withStepDefaults(node, ctx) : node;
|
|
662
664
|
return (_a = unfoldUsage(element, name, ctx)) !== null && _a !== void 0 ? _a : unfoldForeignUsage(element, name, ctx);
|
|
663
665
|
}
|
|
666
|
+
/**
|
|
667
|
+
* A `Variation` becomes its options' labels in bold, followed by its content. One whose `is`
|
|
668
|
+
* cannot be evaluated keeps its tag, and one with no valid ids renders nothing, as on the page.
|
|
669
|
+
*/
|
|
670
|
+
function unfoldVariation(node, ctx) {
|
|
671
|
+
const failed = new Set();
|
|
672
|
+
const props = collectUsageProps(node, ctx, failed);
|
|
673
|
+
if (failed.has('is') || failed.has(FAILED_SPREAD))
|
|
674
|
+
return undefined;
|
|
675
|
+
const ids = variationIds(props.get('is'));
|
|
676
|
+
if (ids.length === 0)
|
|
677
|
+
return [];
|
|
678
|
+
const title = ids.map((id) => { var _a, _b; return (_b = (_a = ctx.variationLabels) === null || _a === void 0 ? void 0 : _a.get(id)) !== null && _b !== void 0 ? _b : id; }).join(', ');
|
|
679
|
+
return wrapPhrasingRuns([
|
|
680
|
+
...parseMarkdown(headlineMarkdown(title, undefined), ctx),
|
|
681
|
+
...transformChildren([...node.children], ctx),
|
|
682
|
+
]);
|
|
683
|
+
}
|
|
684
|
+
const isStaticArray = (value) => Array.isArray(value);
|
|
685
|
+
function variationIds(value) {
|
|
686
|
+
const values = isStaticArray(value) ? value : [value];
|
|
687
|
+
const ids = values.map((id) => (typeof id === 'string' ? id.trim() : ''));
|
|
688
|
+
return ids.every((id) => id !== '') ? ids : [];
|
|
689
|
+
}
|
|
664
690
|
/** `Steps` numbers its `Step` children and passes its `titleSize` down; a Step's own props win. */
|
|
665
691
|
function withStepDefaults(node, ctx) {
|
|
666
692
|
const titleSize = collectUsageProps(node, ctx).get('titleSize');
|
|
@@ -859,9 +885,9 @@ function normalizeGfmAlerts(nodes) {
|
|
|
859
885
|
}
|
|
860
886
|
}
|
|
861
887
|
}
|
|
862
|
-
export const remarkVisibilityForMarkdown = () => (tree) => {
|
|
888
|
+
export const remarkVisibilityForMarkdown = ({ variationLabels } = {}) => (tree) => {
|
|
863
889
|
const componentContext = collectMarkdownComponentContext(tree);
|
|
864
|
-
const ctx = Object.assign(Object.assign({}, componentContext), { stack: [], budget: createUnfoldBudget() });
|
|
890
|
+
const ctx = Object.assign(Object.assign({}, componentContext), { stack: [], budget: createUnfoldBudget(), variationLabels: new Map(Object.entries(variationLabels !== null && variationLabels !== void 0 ? variationLabels : {})) });
|
|
865
891
|
tree.children = transformChildren(tree.children, ctx);
|
|
866
892
|
normalizeGfmAlerts(tree.children);
|
|
867
893
|
};
|
|
@@ -25,6 +25,8 @@ export type UnfoldContext = MarkdownComponentContext & {
|
|
|
25
25
|
* At the page level this is the literal scope.
|
|
26
26
|
*/
|
|
27
27
|
trusted?: EvalEnv;
|
|
28
|
+
/** `docs.json` variation labels by id. */
|
|
29
|
+
variationLabels?: ReadonlyMap<string, string>;
|
|
28
30
|
};
|
|
29
31
|
/** The environment holding only values that no write the evaluator cannot see can make stale. */
|
|
30
32
|
export declare function trustedEnv(ctx: UnfoldContext): EvalEnv;
|
|
@@ -274,7 +274,7 @@ export function dropPairedDarkOnly(children, classOf) {
|
|
|
274
274
|
});
|
|
275
275
|
return children.filter((_, index) => !dropped.has(index));
|
|
276
276
|
}
|
|
277
|
-
export const KEEP_TAG_COMPONENTS = new Set(['Variation', '
|
|
277
|
+
export const KEEP_TAG_COMPONENTS = new Set(['Variation', 'Snippet']);
|
|
278
278
|
export const HEADLINE_ATTRIBUTES = ['title', 'label', 'name', 'path'];
|
|
279
279
|
export const GFM_ALERT_PATTERN = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/;
|
|
280
280
|
export function prefixBlockquoteLines(text) {
|
package/dist/mdx/remark.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type RemarkUserMentionsOptions } from './plugins/remark/remarkUserMentions.js';
|
|
2
|
+
import { type RemarkVisibilityForMarkdownOptions } from './plugins/remark/remarkVisibilityForMarkdown.js';
|
|
2
3
|
export { coreRemark, coreRemarkMdxPlugins, getAST, stringifyTree, stringifyTreeForAgents, } from './remark-core.js';
|
|
3
4
|
export declare function stripVisibilityForMarkdown(mdx: string): string;
|
|
4
|
-
export
|
|
5
|
+
export type TransformContentForMarkdownOptions = RemarkUserMentionsOptions & RemarkVisibilityForMarkdownOptions;
|
|
6
|
+
export declare function transformContentForMarkdown(mdx: string, { variationLabels, ...mentionOptions }?: TransformContentForMarkdownOptions): string;
|
package/dist/mdx/remark.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { remarkUserMentions, } from './plugins/remark/remarkUserMentions.js';
|
|
2
|
-
import { remarkVisibilityForMarkdown } from './plugins/remark/remarkVisibilityForMarkdown.js';
|
|
13
|
+
import { remarkVisibilityForMarkdown, } from './plugins/remark/remarkVisibilityForMarkdown.js';
|
|
3
14
|
import { getAST, stringifyTreeForAgents } from './remark-core.js';
|
|
4
15
|
export { coreRemark, coreRemarkMdxPlugins, getAST, stringifyTree, stringifyTreeForAgents, } from './remark-core.js';
|
|
5
16
|
export function stripVisibilityForMarkdown(mdx) {
|
|
@@ -7,9 +18,10 @@ export function stripVisibilityForMarkdown(mdx) {
|
|
|
7
18
|
remarkVisibilityForMarkdown()(tree);
|
|
8
19
|
return stringifyTreeForAgents(tree);
|
|
9
20
|
}
|
|
10
|
-
export function transformContentForMarkdown(mdx,
|
|
21
|
+
export function transformContentForMarkdown(mdx, _a = {}) {
|
|
22
|
+
var { variationLabels } = _a, mentionOptions = __rest(_a, ["variationLabels"]);
|
|
11
23
|
const tree = getAST(mdx);
|
|
12
|
-
remarkVisibilityForMarkdown()(tree);
|
|
24
|
+
remarkVisibilityForMarkdown({ variationLabels })(tree);
|
|
13
25
|
remarkUserMentions(mentionOptions)(tree);
|
|
14
26
|
return stringifyTreeForAgents(tree);
|
|
15
27
|
}
|