@mintlify/common 1.0.1260 → 1.0.1262

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.
@@ -3,6 +3,5 @@ import type { MdxjsEsm } from 'mdast-util-mdx';
3
3
  import { Node, Parent } from 'unist';
4
4
  import { VFile } from 'vfile';
5
5
  export declare const injectedSnippetFile: (node: MdxjsEsm) => string | undefined;
6
- export declare const snippetFileOf: (node: Node) => string | undefined;
7
6
  export declare const findSnippetCycle: (tree: Node, snippetTreeMap: Record<string, Root>) => string[] | undefined;
8
7
  export declare const remarkMdxInjectSnippets: (snippetTreeMap: Record<string, Root>) => (tree: Parent, file: VFile) => void;
@@ -6,7 +6,7 @@ export const injectedSnippetFile = (node) => {
6
6
  ? data.snippetFile
7
7
  : undefined;
8
8
  };
9
- export const snippetFileOf = (node) => {
9
+ const snippetFileOf = (node) => {
10
10
  if (node.type !== 'mdxJsxFlowElement')
11
11
  return undefined;
12
12
  const mdxJsxFlowElement = node;
@@ -3,5 +3,4 @@ export type Snippet = {
3
3
  snippetFileLocation: string;
4
4
  content: string;
5
5
  };
6
- export declare function collectReferencedSnippets(content: string, snippets: Snippet[]): string[];
7
6
  export declare function createSnippetTreeMap(snippets: Snippet[]): Promise<Record<string, Root>>;
@@ -12,56 +12,7 @@ import { gfmFromMarkdown } from 'mdast-util-gfm';
12
12
  import { mdxFromMarkdown } from 'mdast-util-mdx';
13
13
  import { gfm } from 'micromark-extension-gfm';
14
14
  import { mdxjs } from 'micromark-extension-mdxjs';
15
- import { visit } from 'unist-util-visit';
16
15
  import { coreRemark, remarkMdxInjectSnippets } from '../../../index.js';
17
- import { snippetFileOf } from '../../plugins/remark/remarkMdxInjectSnippets.js';
18
- import { getReferencedSnippetPaths } from './getReferencedSnippetPaths.js';
19
- export function collectReferencedSnippets(content, snippets) {
20
- const byLocation = new Map(snippets.map((snippet) => [snippet.snippetFileLocation, snippet.content]));
21
- const seen = new Set();
22
- const referenced = [];
23
- const pending = [content];
24
- let current = pending.pop();
25
- while (current !== undefined) {
26
- const locations = current.includes('<Snippet') ? findSnippetReferences(current) : [];
27
- for (const location of locations) {
28
- if (seen.has(location))
29
- continue;
30
- seen.add(location);
31
- const snippet = byLocation.get(location);
32
- if (snippet !== undefined) {
33
- referenced.push(snippet);
34
- pending.push(snippet);
35
- }
36
- }
37
- current = pending.pop();
38
- }
39
- return referenced;
40
- }
41
- function findSnippetReferences(content) {
42
- let tree;
43
- try {
44
- tree = parseSnippetTree(content);
45
- }
46
- catch (_a) {
47
- return getReferencedSnippetPaths(content);
48
- }
49
- const references = [];
50
- visit(tree, (node) => {
51
- var _a;
52
- const file = node.type === 'mdxJsxTextElement' && node.name === 'Snippet'
53
- ? (_a = node.attributes.find((attr) => attr.type === 'mdxJsxAttribute' && attr.name === 'file')) === null || _a === void 0 ? void 0 : _a.value
54
- : snippetFileOf(node);
55
- if (typeof file === 'string') {
56
- references.push(file);
57
- }
58
- else if ((node.type === 'mdxFlowExpression' || node.type === 'mdxTextExpression') &&
59
- node.value.includes('<Snippet')) {
60
- references.push(...getReferencedSnippetPaths(node.value));
61
- }
62
- });
63
- return references;
64
- }
65
16
  export function createSnippetTreeMap(snippets) {
66
17
  return __awaiter(this, void 0, void 0, function* () {
67
18
  var _a;
@@ -17,7 +17,7 @@ import { PackageIslandsError, parsePackageIslands, preprocessPageContent, } from
17
17
  import { preprocessCustomHeadingIds } from '../preprocessCustomHeadingIds.js';
18
18
  import { preprocessMdxFragmentCode } from '../preprocessMdxFragmentCode.js';
19
19
  import { replaceVariables } from '../replaceVariables.js';
20
- import { collectReferencedSnippets, createSnippetTreeMap, } from './getMdx/snippets.js';
20
+ import { createSnippetTreeMap } from './getMdx/snippets.js';
21
21
  import { getSerializeExtras } from './getSerializeExtras.js';
22
22
  const getPackageIslandOptions = (packageBuild, pagePath, processedContent) => {
23
23
  const buildBaseUrl = packageBuildBaseUrl(packageBuild.buildId);
@@ -54,14 +54,7 @@ export function getMdx(_a) {
54
54
  if (!tailwindSelectors) {
55
55
  const hasClasses = [processedContent, ...processedSnippets.map(({ content }) => content)].some(hasClassAttribute);
56
56
  tailwindSelectors = hasClasses
57
- ? yield traceFn('getMdx.getTailwindSelectors', () => __awaiter(this, void 0, void 0, function* () {
58
- return getTailwindSelectors({
59
- content: [
60
- processedContent,
61
- ...collectReferencedSnippets(processedContent, processedSnippets),
62
- ].join('\n'),
63
- });
64
- }))
57
+ ? yield traceFn('getMdx.getTailwindSelectors', () => __awaiter(this, void 0, void 0, function* () { return getTailwindSelectors({ content: processedContent }); }))
65
58
  : [];
66
59
  }
67
60
  const snippetTreeMap = yield traceFn('getMdx.createSnippetTreeMap', () => __awaiter(this, void 0, void 0, function* () { return createSnippetTreeMap(processedSnippets); }));