@mintlify/common 1.0.477 → 1.0.478

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.
@@ -0,0 +1,2 @@
1
+ import { getDynamicTailwindCss, getTailwindSelectors } from './tailwind.js';
2
+ export { getDynamicTailwindCss, getTailwindSelectors };
@@ -0,0 +1,2 @@
1
+ import { getDynamicTailwindCss, getTailwindSelectors } from './tailwind.js';
2
+ export { getDynamicTailwindCss, getTailwindSelectors };
@@ -0,0 +1,8 @@
1
+ /** Get generated TailwindCSS from the content with prefix added to each class */
2
+ export declare function getDynamicTailwindCss({ content, prefix, }: {
3
+ content: string;
4
+ prefix?: string;
5
+ }): Promise<string>;
6
+ export declare function getTailwindSelectors({ content }: {
7
+ content: string;
8
+ }): Promise<string[]>;
@@ -0,0 +1,59 @@
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 postcss from 'postcss';
11
+ import tailwindcss from 'tailwindcss';
12
+ import { MINTLIFY_TAILWIND_PREFIX } from '../index.js';
13
+ function removeDarkClassNamePrefix(css) {
14
+ return css.replace(/\.mint-dark \*/g, '.dark *');
15
+ }
16
+ function getAllSelectors(nodes) {
17
+ const selectors = [];
18
+ for (const node of nodes) {
19
+ if (node.type === 'rule') {
20
+ selectors.push(node.selector);
21
+ }
22
+ else if (node.type === 'atrule' && node.nodes) {
23
+ selectors.push(...getAllSelectors(node.nodes));
24
+ }
25
+ }
26
+ return selectors;
27
+ }
28
+ function getContent(content) {
29
+ const extensions = ['html', 'tsx', 'mdx'];
30
+ return extensions.map((extension) => ({ raw: content, extension }));
31
+ }
32
+ /** Get generated TailwindCSS from the content with prefix added to each class */
33
+ export function getDynamicTailwindCss(_a) {
34
+ return __awaiter(this, arguments, void 0, function* ({ content, prefix = MINTLIFY_TAILWIND_PREFIX, }) {
35
+ const css = `@tailwind utilities;`;
36
+ const tailwindPlugin = tailwindcss({
37
+ content: getContent(content),
38
+ corePlugins: { preflight: false },
39
+ prefix,
40
+ darkMode: 'class',
41
+ });
42
+ const result = yield postcss([tailwindPlugin]).process(css, { from: undefined });
43
+ result.css = removeDarkClassNamePrefix(result.css);
44
+ return result.css;
45
+ });
46
+ }
47
+ export function getTailwindSelectors(_a) {
48
+ return __awaiter(this, arguments, void 0, function* ({ content }) {
49
+ const css = `@tailwind utilities;`;
50
+ const tailwindPlugin = tailwindcss({
51
+ content: getContent(content),
52
+ corePlugins: { preflight: false },
53
+ darkMode: 'class',
54
+ });
55
+ const result = yield postcss([tailwindPlugin]).process(css, { from: undefined });
56
+ const selectors = getAllSelectors(result.root.nodes);
57
+ return selectors;
58
+ });
59
+ }
@@ -10,5 +10,14 @@ export type GetMdxType = {
10
10
  panelMdxSource?: SerializeSuccess;
11
11
  panelMdxSourceWithNoJs?: SerializeSuccess;
12
12
  };
13
- export declare function getMdx(path: string, content: string, metadata: PageMetaTags, snippets: Snippet[], subdomain: string, config: DocsConfig, tailwindSelectors: string[], pageType?: 'default' | 'pdf'): Promise<GetMdxType>;
13
+ export declare function getMdx({ path, content, metadata, snippets, subdomain, config, tailwindSelectors, pageType, }: {
14
+ path: string;
15
+ content: string;
16
+ metadata: PageMetaTags;
17
+ snippets: Snippet[];
18
+ subdomain: string;
19
+ config: DocsConfig;
20
+ tailwindSelectors?: string[] | undefined;
21
+ pageType?: 'default' | 'pdf';
22
+ }): Promise<GetMdxType>;
14
23
  export { createSnippetTreeMap, type Snippet };
@@ -8,10 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { serialize } from '@mintlify/mdx';
11
+ import { getTailwindSelectors } from '../../css/tailwind.js';
11
12
  import { getMDXOptions, remarkMdxRemoveJs, remarkExpandContent, remarkSplitCodeGroup, remarkSplitTabs, remarkValidateSteps, remarkValidateTabs, } from '../../index.js';
12
13
  import { createSnippetTreeMap } from './getMdx/snippets.js';
13
- export function getMdx(path_1, content_1, metadata_1, snippets_1, subdomain_1, config_1, tailwindSelectors_1) {
14
- return __awaiter(this, arguments, void 0, function* (path, content, metadata, snippets, subdomain, config, tailwindSelectors, pageType = 'default') {
14
+ export function getMdx(_a) {
15
+ return __awaiter(this, arguments, void 0, function* ({ path, content, metadata, snippets, subdomain, config, tailwindSelectors = undefined, pageType = 'default', }) {
16
+ if (!tailwindSelectors)
17
+ tailwindSelectors = yield getTailwindSelectors({ content });
15
18
  const snippetTreeMap = yield createSnippetTreeMap(snippets);
16
19
  const mdxOptionsData = {
17
20
  subdomain,