@mintlify/common 1.0.1281 → 1.0.1282

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.
@@ -1,4 +1,5 @@
1
1
  export * from './mdx-utils.js';
2
2
  export * from './remark-utils.js';
3
+ export * from './unicode-id.js';
3
4
  export * from './findExportedNode.js';
4
5
  export * from './node-text.js';
@@ -1,4 +1,5 @@
1
1
  export * from './mdx-utils.js';
2
2
  export * from './remark-utils.js';
3
+ export * from './unicode-id.js';
3
4
  export * from './findExportedNode.js';
4
5
  export * from './node-text.js';
@@ -7,6 +7,5 @@ export declare const createMdxJsxAttribute: (key: string, value: MdxJsxAttribute
7
7
  export declare function getTitleMarkdownText(node: {
8
8
  data?: Data;
9
9
  }, fallback: string): string;
10
- export declare function getUnicodeId(title: string): string;
11
10
  export declare const getTableOfContentsTitle: (node: RootContent, index?: number, children?: RootContent[]) => string;
12
11
  export {};
@@ -15,9 +15,6 @@ export function getTitleMarkdownText(node, fallback) {
15
15
  ? data.text
16
16
  : fallback;
17
17
  }
18
- export function getUnicodeId(title) {
19
- return encodeURIComponent(title.toLowerCase().trim().replace(/\s+/g, '-'));
20
- }
21
18
  const EMPTY_CHILDREN = [];
22
19
  export const getTableOfContentsTitle = (node, index = 1, children = EMPTY_CHILDREN) => {
23
20
  var _a;
@@ -0,0 +1 @@
1
+ export declare function getUnicodeId(title: string): string;
@@ -0,0 +1,3 @@
1
+ export function getUnicodeId(title) {
2
+ return encodeURIComponent(title.toLowerCase().trim().replace(/\s+/g, '-'));
3
+ }
@@ -1,5 +1,6 @@
1
1
  import { visit } from 'unist-util-visit';
2
- import { getUnicodeId, getTableOfContentsTitle } from '../../lib/remark-utils.js';
2
+ import { getTableOfContentsTitle } from '../../lib/remark-utils.js';
3
+ import { getUnicodeId } from '../../lib/unicode-id.js';
3
4
  const DEEPLINKABLE_COMPONENTS = ['Heading', 'Update', 'Accordion', 'Tab'];
4
5
  export const rehypeUnicodeIds = () => {
5
6
  return (tree) => {
@@ -0,0 +1,3 @@
1
+ export declare function generateComponentId(title: string, count?: number): string;
2
+ export declare const CHILD_TAB_IDS_ATTRIBUTE = "data-child-tab-ids";
3
+ export declare const CHILD_HEADING_IDS_ATTRIBUTE = "data-child-heading-ids";
@@ -0,0 +1,7 @@
1
+ import { cachedSlugify } from '../../../slugify.js';
2
+ export function generateComponentId(title, count) {
3
+ const base = cachedSlugify(title.replace(':', '-'), { decamelize: false });
4
+ return count != null && count > 0 ? `${base}-${count}` : base;
5
+ }
6
+ export const CHILD_TAB_IDS_ATTRIBUTE = 'data-child-tab-ids';
7
+ export const CHILD_HEADING_IDS_ATTRIBUTE = 'data-child-heading-ids';
@@ -17,6 +17,7 @@ export * from './remarkSplitCodeGroup.js';
17
17
  export * from './remarkWrapCodeBlocks.js';
18
18
  export * from './remarkSplitTabs.js';
19
19
  export * from './remarkComponentIds.js';
20
+ export * from './component-ids.js';
20
21
  export * from './remarkMdxExtractPanel.js';
21
22
  export * from './remarkValidateAccordions.js';
22
23
  export * from './remarkValidateSteps.js';
@@ -33,5 +34,6 @@ export * from './remarkUnwrapJsxHeadings.js';
33
34
  export { TITLE_COMPONENTS } from './remarkTitleMarkdown.js';
34
35
  export * from './remarkUserMentions.js';
35
36
  export * from './remarkVisibilityForMarkdown.js';
37
+ export * from './visibility-auth-rule.js';
36
38
  export * from './pureTemplateComponents.js';
37
39
  export * from './remarkPrefixMediaBasePath.js';
@@ -17,6 +17,7 @@ export * from './remarkSplitCodeGroup.js';
17
17
  export * from './remarkWrapCodeBlocks.js';
18
18
  export * from './remarkSplitTabs.js';
19
19
  export * from './remarkComponentIds.js';
20
+ export * from './component-ids.js';
20
21
  export * from './remarkMdxExtractPanel.js';
21
22
  export * from './remarkValidateAccordions.js';
22
23
  export * from './remarkValidateSteps.js';
@@ -33,5 +34,6 @@ export * from './remarkUnwrapJsxHeadings.js';
33
34
  export { TITLE_COMPONENTS } from './remarkTitleMarkdown.js';
34
35
  export * from './remarkUserMentions.js';
35
36
  export * from './remarkVisibilityForMarkdown.js';
37
+ export * from './visibility-auth-rule.js';
36
38
  export * from './pureTemplateComponents.js';
37
39
  export * from './remarkPrefixMediaBasePath.js';
@@ -1,8 +1,5 @@
1
1
  import type { PageMetaTags } from '@mintlify/models';
2
2
  import type { Root } from 'mdast';
3
- export declare function generateComponentId(title: string, count?: number): string;
4
3
  export declare const HEADING_LEVELS: number[];
5
4
  export declare const AVOIDED_PAGE_MODES: string[];
6
- export declare const CHILD_TAB_IDS_ATTRIBUTE = "data-child-tab-ids";
7
- export declare const CHILD_HEADING_IDS_ATTRIBUTE = "data-child-heading-ids";
8
5
  export declare const remarkComponentIds: (pageMetadata?: PageMetaTags) => (tree: Root) => void;
@@ -1,14 +1,9 @@
1
1
  import { visit } from 'unist-util-visit';
2
- import { cachedSlugify, cachedSlugifyWithCounter, slugify } from '../../../slugify.js';
2
+ import { cachedSlugifyWithCounter, slugify } from '../../../slugify.js';
3
3
  import { createMdxJsxAttribute, getTableOfContentsTitle, getTitleMarkdownText, } from '../../lib/remark-utils.js';
4
- export function generateComponentId(title, count) {
5
- const base = cachedSlugify(title.replace(':', '-'), { decamelize: false });
6
- return count != null && count > 0 ? `${base}-${count}` : base;
7
- }
4
+ import { CHILD_HEADING_IDS_ATTRIBUTE, CHILD_TAB_IDS_ATTRIBUTE, generateComponentId, } from './component-ids.js';
8
5
  export const HEADING_LEVELS = [1, 2, 3, 4];
9
6
  export const AVOIDED_PAGE_MODES = ['custom', 'frame'];
10
- export const CHILD_TAB_IDS_ATTRIBUTE = 'data-child-tab-ids';
11
- export const CHILD_HEADING_IDS_ATTRIBUTE = 'data-child-heading-ids';
12
7
  export const remarkComponentIds = (pageMetadata) => (tree) => {
13
8
  var _a;
14
9
  const slugifyFn = cachedSlugifyWithCounter();
@@ -6,8 +6,9 @@ import { createMdxJsxAttribute, getTableOfContentsTitle, getTitleMarkdownText, }
6
6
  import { createSlugDeduplicator } from '../../lib/slug-deduplicator.js';
7
7
  import { isMdxJsxFragment } from '../../utils.js';
8
8
  import { AVOIDED_PAGE_MODES, HEADING_LEVELS } from './remarkComponentIds.js';
9
- import { isHiddenFromHumans, isVisibilityElement, resolveVisibilityFor, toPageGroups, toVisibilityAuthRule, } from './remarkVisibilityForMarkdown.js';
9
+ import { isHiddenFromHumans, isVisibilityElement, resolveVisibilityFor, toVisibilityAuthRule, } from './remarkVisibilityForMarkdown.js';
10
10
  import { isVariationElement, resolveVariationIds } from './variation.js';
11
+ import { toPageGroups } from './visibility-auth-rule.js';
11
12
  export const HEADING_NAMES = ['h1', 'h2', 'h3', 'h4'];
12
13
  const COMPONENTS_TO_EXCLUDE_HEADINGS = [
13
14
  'Accordion',
@@ -1,4 +1,4 @@
1
1
  import type { Root } from 'mdast';
2
2
  export declare const remarkMdxRemoveUnknownJsx: ({ allowlist }?: {
3
3
  allowlist?: string[];
4
- }) => (tree: Root) => Root | import("mdast-util-mdx-jsx").MdxJsxFlowElement | import("mdast").Link | import("mdast").Delete | import("mdast").Code | import("mdast").Blockquote | import("mdast").Break | import("mdast").Definition | import("mdast").Emphasis | 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").Strong | import("mdast").Table | import("mdast").TableCell | import("mdast").TableRow | import("mdast").Text | import("mdast").ThematicBreak | import("mdast").Yaml | import("mdast-util-mdx-jsx").MdxJsxTextElement | import("mdast-util-math").InlineMath | import("mdast-util-math").Math | import("mdast-util-mdx-expression").MdxTextExpression | import("mdast-util-mdx-expression").MdxFlowExpression | import("mdast-util-mdxjs-esm").MdxjsEsm;
4
+ }) => (tree: Root) => Root | import("mdast-util-mdx-jsx").MdxJsxFlowElement | import("mdast-util-mdx-jsx").MdxJsxTextElement | import("mdast").Link | import("mdast").Delete | import("mdast").Code | import("mdast").Text | import("mdast").Heading | import("mdast").Blockquote | import("mdast").Break | import("mdast").Definition | import("mdast").Emphasis | import("mdast").FootnoteDefinition | import("mdast").FootnoteReference | 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").Strong | import("mdast").Table | import("mdast").TableCell | import("mdast").TableRow | import("mdast").ThematicBreak | import("mdast").Yaml | import("mdast-util-math").InlineMath | import("mdast-util-math").Math | import("mdast-util-mdx-expression").MdxTextExpression | import("mdast-util-mdx-expression").MdxFlowExpression | import("mdast-util-mdxjs-esm").MdxjsEsm;
@@ -1,5 +1,5 @@
1
1
  import { visit } from 'unist-util-visit';
2
- import { generateComponentId } from './remarkComponentIds.js';
2
+ import { generateComponentId } from './component-ids.js';
3
3
  const findAttribute = (node, name) => node.attributes.find((attr) => attr.type === 'mdxJsxAttribute' && attr.name === name);
4
4
  export const remarkValidateAccordions = () => (tree) => {
5
5
  const seenSlugs = new Set();
@@ -1,7 +1,7 @@
1
- import type { PageGroupRule, PageGroups } from '@mintlify/models';
2
1
  import type { Root } from 'mdast';
3
2
  import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
4
3
  import { type StaticScope } from './staticEvaluator.js';
4
+ import { type VisibilityAuthRule, type VisibilityGroups } from './visibility-auth-rule.js';
5
5
  export type MdxJsxElement = MdxJsxFlowElement | MdxJsxTextElement;
6
6
  export declare function isVisibilityElement(node: {
7
7
  type: string;
@@ -10,15 +10,6 @@ export declare function isVisibilityElement(node: {
10
10
  export declare const VISIBILITY_AUDIENCES: readonly ["humans", "agents", "signed-in", "signed-out"];
11
11
  export type VisibilityAudience = (typeof VISIBILITY_AUDIENCES)[number];
12
12
  export declare const VISIBILITY_FOR_EXPECTED = "\"humans\", \"agents\", \"signed-in\", \"signed-out\", or { groups: [...] }";
13
- export type VisibilityGroups = string[] | PageGroupRule;
14
- export type VisibilityGroupsRule = {
15
- groups: VisibilityGroups;
16
- };
17
- export type VisibilityAuthRule = 'signed-in' | 'signed-out' | VisibilityGroupsRule;
18
- export type VisibilityViewer = {
19
- signedIn: boolean;
20
- groups: readonly string[];
21
- };
22
13
  export type VisibilityResolution = {
23
14
  kind: 'audience';
24
15
  audience: VisibilityAudience;
@@ -34,8 +25,6 @@ export type VisibilityResolution = {
34
25
  kind: 'missing';
35
26
  };
36
27
  export declare function isVisibilityAudience(value: unknown): value is VisibilityAudience;
37
- export declare const toPageGroups: (groups: VisibilityGroups) => PageGroups;
38
- export declare function toVisibilityGroupsRule(value: unknown): VisibilityGroupsRule | undefined;
39
28
  /**
40
29
  * Resolves a `Visibility` audience. With `literalScope`, an evaluated audience that shows content
41
30
  * to agents must resolve the same from literal values alone; otherwise it is dynamic, since an
@@ -45,5 +34,4 @@ export declare function resolveVisibilityFor(node: MdxJsxElement, scope?: Static
45
34
  export declare function isHiddenFromHumans(resolution: VisibilityResolution): boolean;
46
35
  export declare function isHiddenFromAgents(resolution: VisibilityResolution): boolean;
47
36
  export declare function toVisibilityAuthRule(resolution: VisibilityResolution): VisibilityAuthRule | undefined;
48
- export declare function matchesVisibilityAuthRule(rule: VisibilityAuthRule, viewer: VisibilityViewer): boolean;
49
37
  export declare const remarkVisibilityForMarkdown: () => (tree: Root) => void;
@@ -1,9 +1,8 @@
1
- import { WILDCARD_GROUP, checkGroupAccess, isPageGroups } from '../../../navigation/groupAccess.js';
2
- import { isObject } from '../../../types/guards.js';
3
1
  import { getAST, stringifyTree } from '../../remark-core.js';
4
2
  import { BLOCK_LINK_LABEL } from './firstPartyMarkdownComponents.js';
5
3
  import { evaluateStatic } from './staticEvaluator.js';
6
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';
5
+ import { toVisibilityGroups, toVisibilityGroupsRule, } from './visibility-auth-rule.js';
7
6
  export function isVisibilityElement(node) {
8
7
  return ((node.type === 'mdxJsxFlowElement' || node.type === 'mdxJsxTextElement') &&
9
8
  node.name === 'Visibility');
@@ -61,28 +60,6 @@ function foldString(node) {
61
60
  return undefined;
62
61
  }
63
62
  }
64
- const trimGroupNames = (names) => [...new Set(names.map((name) => name.trim()))];
65
- const isGroupNames = (groups) => groups.every((entry) => typeof entry === 'string');
66
- export const toPageGroups = (groups) => Array.isArray(groups) ? groups : [groups];
67
- function toVisibilityGroups(value) {
68
- if (Array.isArray(value)) {
69
- if (value.length === 0 || !isPageGroups(value) || !isGroupNames(value))
70
- return undefined;
71
- const names = trimGroupNames(value);
72
- return isPageGroups(names) ? names : undefined;
73
- }
74
- const rules = [value];
75
- if (!isPageGroups(rules) || isGroupNames(rules))
76
- return undefined;
77
- const [rule] = rules.map(({ includes, excludes }) => (Object.assign(Object.assign({}, (includes && { includes: trimGroupNames(includes) })), (excludes && { excludes: trimGroupNames(excludes) }))));
78
- return rule && isPageGroups([rule]) ? rule : undefined;
79
- }
80
- export function toVisibilityGroupsRule(value) {
81
- if (!isObject(value) || Object.keys(value).length !== 1)
82
- return undefined;
83
- const groups = toVisibilityGroups(value.groups);
84
- return groups && { groups };
85
- }
86
63
  function staticKey(property) {
87
64
  if (property.type !== 'Property' || property.computed)
88
65
  return undefined;
@@ -263,13 +240,6 @@ export function toVisibilityAuthRule(resolution) {
263
240
  }
264
241
  return undefined;
265
242
  }
266
- export function matchesVisibilityAuthRule(rule, viewer) {
267
- if (rule === 'signed-in')
268
- return viewer.signedIn;
269
- if (rule === 'signed-out')
270
- return !viewer.signedIn;
271
- return checkGroupAccess(toPageGroups(rule.groups), new Set(viewer.signedIn ? [...viewer.groups, WILDCARD_GROUP] : []));
272
- }
273
243
  function transformChildren(children, ctx) {
274
244
  return dropPairedDarkOnly(children, (child) => usageClassName(child, ctx)).flatMap((child) => transformNode(child, ctx));
275
245
  }
@@ -0,0 +1,14 @@
1
+ import type { PageGroupRule, PageGroups } from '@mintlify/models';
2
+ export type VisibilityGroups = string[] | PageGroupRule;
3
+ export type VisibilityGroupsRule = {
4
+ groups: VisibilityGroups;
5
+ };
6
+ export type VisibilityAuthRule = 'signed-in' | 'signed-out' | VisibilityGroupsRule;
7
+ export type VisibilityViewer = {
8
+ signedIn: boolean;
9
+ groups: readonly string[];
10
+ };
11
+ export declare const toPageGroups: (groups: VisibilityGroups) => PageGroups;
12
+ export declare function toVisibilityGroups(value: unknown): VisibilityGroups | undefined;
13
+ export declare function toVisibilityGroupsRule(value: unknown): VisibilityGroupsRule | undefined;
14
+ export declare function matchesVisibilityAuthRule(rule: VisibilityAuthRule, viewer: VisibilityViewer): boolean;
@@ -0,0 +1,31 @@
1
+ import { WILDCARD_GROUP, checkGroupAccess, isPageGroups } from '../../../navigation/groupAccess.js';
2
+ import { isObject } from '../../../types/guards.js';
3
+ const trimGroupNames = (names) => [...new Set(names.map((name) => name.trim()))];
4
+ const isGroupNames = (groups) => groups.every((entry) => typeof entry === 'string');
5
+ export const toPageGroups = (groups) => Array.isArray(groups) ? groups : [groups];
6
+ export function toVisibilityGroups(value) {
7
+ if (Array.isArray(value)) {
8
+ if (value.length === 0 || !isPageGroups(value) || !isGroupNames(value))
9
+ return undefined;
10
+ const names = trimGroupNames(value);
11
+ return isPageGroups(names) ? names : undefined;
12
+ }
13
+ const rules = [value];
14
+ if (!isPageGroups(rules) || isGroupNames(rules))
15
+ return undefined;
16
+ const [rule] = rules.map(({ includes, excludes }) => (Object.assign(Object.assign({}, (includes && { includes: trimGroupNames(includes) })), (excludes && { excludes: trimGroupNames(excludes) }))));
17
+ return rule && isPageGroups([rule]) ? rule : undefined;
18
+ }
19
+ export function toVisibilityGroupsRule(value) {
20
+ if (!isObject(value) || Object.keys(value).length !== 1)
21
+ return undefined;
22
+ const groups = toVisibilityGroups(value.groups);
23
+ return groups && { groups };
24
+ }
25
+ export function matchesVisibilityAuthRule(rule, viewer) {
26
+ if (rule === 'signed-in')
27
+ return viewer.signedIn;
28
+ if (rule === 'signed-out')
29
+ return !viewer.signedIn;
30
+ return checkGroupAccess(toPageGroups(rule.groups), new Set(viewer.signedIn ? [...viewer.groups, WILDCARD_GROUP] : []));
31
+ }
package/dist/slugify.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import librarySlugify from '@sindresorhus/slugify';
2
- import { getUnicodeId } from './mdx/lib/remark-utils.js';
2
+ import { getUnicodeId } from './mdx/lib/unicode-id.js';
3
3
  // decodes percent-encoded slugs and strips punctuation + emoji so the
4
4
  // resulting ID matches what the client renders in the DOM
5
5
  export const cleanHeadingId = (id) => {