@mintlify/common 1.0.1207 → 1.0.1209

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.
@@ -5,6 +5,9 @@ export type PotentialFileCategory = 'page' | 'snippet' | 'mintConfig' | 'potenti
5
5
  export type FileCategory = Omit<PotentialFileCategory, 'potentialYamlOpenApiSpec' | 'potentialJsonOpenApiSpec'> | 'openApi' | null;
6
6
  export declare const generatedStaticFiles: readonly ["llms.txt", "robots.txt", "sitemap.xml", "llms-full.txt"];
7
7
  export type GeneratedStaticFile = (typeof generatedStaticFiles)[number];
8
+ export declare const packageManifestFiles: readonly ["package.json", "package-lock.json", "pnpm-lock.yaml"];
9
+ export type PackageManifestFile = (typeof packageManifestFiles)[number];
10
+ export declare const isPackageManifestPath: (filePath: string) => boolean;
8
11
  export declare const IMAGE_FORMATS: string[];
9
12
  export declare const VIDEO_FORMATS: string[];
10
13
  export declare const AUDIO_FORMATS: string[];
@@ -9,6 +9,15 @@ export const generatedStaticFiles = [
9
9
  'sitemap.xml',
10
10
  'llms-full.txt',
11
11
  ];
12
+ export const packageManifestFiles = [
13
+ 'package.json',
14
+ 'package-lock.json',
15
+ 'pnpm-lock.yaml',
16
+ ];
17
+ export const isPackageManifestPath = (filePath) => {
18
+ const normalizedPath = optionallyRemoveLeadingSlash(filePath);
19
+ return packageManifestFiles.some((name) => name === normalizedPath);
20
+ };
12
21
  export const IMAGE_FORMATS = [
13
22
  '.jpeg',
14
23
  '.jpg',
package/dist/index.d.ts CHANGED
@@ -27,6 +27,7 @@ export * from './services/aws.js';
27
27
  export * from './slugify.js';
28
28
  export * from './services/aws.js';
29
29
  export * from './truncateAtWordBoundary.js';
30
+ export * from './strip-markdown.js';
30
31
  export * from './api-reference/parseApiTargetFromMetadata.js';
31
32
  export * from './mintIgnore.js';
32
33
  export * from './getDisplayDomain.js';
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ export * from './services/aws.js';
27
27
  export * from './slugify.js';
28
28
  export * from './services/aws.js';
29
29
  export * from './truncateAtWordBoundary.js';
30
+ export * from './strip-markdown.js';
30
31
  export * from './api-reference/parseApiTargetFromMetadata.js';
31
32
  export * from './mintIgnore.js';
32
33
  export * from './getDisplayDomain.js';
@@ -12,5 +12,6 @@ export * from './removeExports.js';
12
12
  export * from './resolveAllImports.js';
13
13
  export * from './resolveImport/index.js';
14
14
  export * from './resolveImportPath.js';
15
+ export * from './isBareSpecifier.js';
15
16
  export * from './isJsxOrTsx.js';
16
17
  export * from './stripTsxTypes.js';
@@ -12,5 +12,6 @@ export * from './removeExports.js';
12
12
  export * from './resolveAllImports.js';
13
13
  export * from './resolveImport/index.js';
14
14
  export * from './resolveImportPath.js';
15
+ export * from './isBareSpecifier.js';
15
16
  export * from './isJsxOrTsx.js';
16
17
  export * from './stripTsxTypes.js';
@@ -0,0 +1,4 @@
1
+ export declare const HOST_PROVIDED_PACKAGES: readonly ["react", "react-dom"];
2
+ export declare const isBareSpecifier: (source: string) => boolean;
3
+ export declare const getSpecifierPackageName: (source: string) => string | undefined;
4
+ export declare const isHostProvidedSpecifier: (source: string) => boolean;
@@ -0,0 +1,27 @@
1
+ const URL_SCHEME_REGEX = /^[a-z][a-z\d+.-]*:/i;
2
+ const NON_BARE_PREFIXES = ['/', './', '../', '#'];
3
+ export const HOST_PROVIDED_PACKAGES = ['react', 'react-dom'];
4
+ export const isBareSpecifier = (source) => {
5
+ if (source === '' || source === '.' || source === '..')
6
+ return false;
7
+ if (NON_BARE_PREFIXES.some((prefix) => source.startsWith(prefix)))
8
+ return false;
9
+ return !URL_SCHEME_REGEX.test(source);
10
+ };
11
+ export const getSpecifierPackageName = (source) => {
12
+ if (!isBareSpecifier(source))
13
+ return undefined;
14
+ const segments = source.split('/');
15
+ if (segments.some((segment) => segment === '.' || segment === '..'))
16
+ return undefined;
17
+ const [first = '', second] = segments;
18
+ if (!first.startsWith('@'))
19
+ return first;
20
+ if (first === '@' || !second)
21
+ return undefined;
22
+ return `${first}/${second}`;
23
+ };
24
+ export const isHostProvidedSpecifier = (source) => {
25
+ const packageName = getSpecifierPackageName(source);
26
+ return HOST_PROVIDED_PACKAGES.some((name) => name === packageName);
27
+ };
@@ -0,0 +1 @@
1
+ export declare const stripMarkdown: (text: string | null | undefined) => string | null;
@@ -0,0 +1,33 @@
1
+ export const stripMarkdown = (text) => {
2
+ if (!text)
3
+ return null;
4
+ return (text
5
+ // Remove images: ![alt](url) → (empty) - handles nested parentheses in URLs
6
+ .replace(/!\[([^\]]*)\]\([^()]*(?:\([^()]*\)[^()]*)*\)/g, '')
7
+ // Remove reference images: ![alt][ref] → (empty)
8
+ .replace(/!\[([^\]]*)\]\[[^\]]*\]/g, '')
9
+ // Remove links: [text](url) → text - handles nested parentheses in URLs and empty text
10
+ .replace(/\[([^\]]*)\]\([^()]*(?:\([^()]*\)[^()]*)*\)/g, '$1')
11
+ // Remove reference links: [text][ref] → text (also handles empty text)
12
+ .replace(/\[([^\]]*)\]\[[^\]]*\]/g, '$1')
13
+ // Remove bold+italic: ***text*** or ___text___ → text
14
+ .replace(/\*{3}([^*]+)\*{3}/g, '$1')
15
+ .replace(/_{3}([^_]+)_{3}/g, '$1')
16
+ // Remove bold: **text** or __text__ → text
17
+ .replace(/\*{2}([^*]+)\*{2}/g, '$1')
18
+ .replace(/_{2}([^_]+)_{2}/g, '$1')
19
+ // Remove italic: *text* or _text_ → text
20
+ .replace(/\*([^*]+)\*/g, '$1')
21
+ .replace(/(?<!\w)_([^_]+)_(?!\w)/g, '$1')
22
+ // Remove code: ```code```, ``code``, `code` → code (order matters)
23
+ .replace(/`{3}([^`]+)`{3}/g, '$1')
24
+ .replace(/`{2}([^`]+)`{2}/g, '$1')
25
+ .replace(/`([^`]+)`/g, '$1')
26
+ // Remove strikethrough: ~~text~~ → text
27
+ .replace(/~~([^~]+)~~/g, '$1')
28
+ // Remove HTML tags (only valid tags starting with letter, not angle brackets in text)
29
+ .replace(/<\/?[a-zA-Z][^>]*>/g, '')
30
+ // Normalize whitespace
31
+ .replace(/\s+/g, ' ')
32
+ .trim());
33
+ };