@mintlify/common 1.0.1253 → 1.0.1255

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.
@@ -11,9 +11,14 @@ export declare function packagePageStylesheets(baseUrl: string, pagePath: string
11
11
  }[];
12
12
  }>>;
13
13
  }): string[];
14
- export declare function compilePackageBuild<T extends {
15
- islands: Readonly<Record<string, unknown>>;
16
- }>(packageBuild: T | undefined): T | undefined;
14
+ type PackageBuildWithOptionalIslands = {
15
+ buildId: string;
16
+ islands?: Readonly<Record<string, unknown>>;
17
+ };
18
+ type WithIslands<T extends PackageBuildWithOptionalIslands> = T & {
19
+ islands: NonNullable<T['islands']>;
20
+ };
21
+ export declare function compilePackageBuild<T extends PackageBuildWithOptionalIslands>(packageBuild: T | undefined): WithIslands<T> | undefined;
17
22
  export declare function withPackageGlobalStylesheets<T extends {
18
23
  packageCssFiles?: string[];
19
24
  }>(mdxExtracts: T, packageBuild: {
@@ -22,3 +27,4 @@ export declare function withPackageGlobalStylesheets<T extends {
22
27
  path: string;
23
28
  }[];
24
29
  } | undefined, pagePath: string): T;
30
+ export {};
@@ -47,8 +47,9 @@ export function packagePageStylesheets(baseUrl, pagePath, islandIds, manifest) {
47
47
  }
48
48
  return [...paths].map((path) => `${pageBaseUrl}/${path}`);
49
49
  }
50
+ const hasIslands = (packageBuild) => packageBuild.islands !== undefined && Object.keys(packageBuild.islands).length > 0;
50
51
  export function compilePackageBuild(packageBuild) {
51
- return packageBuild && Object.keys(packageBuild.islands).length > 0 ? packageBuild : undefined;
52
+ return packageBuild && hasIslands(packageBuild) ? packageBuild : undefined;
52
53
  }
53
54
  export function withPackageGlobalStylesheets(mdxExtracts, packageBuild, pagePath) {
54
55
  var _a, _b;
@@ -26,7 +26,6 @@ export type ClassifyPackageSourcesOptions = {
26
26
  export type ClassifiedPackageSources = {
27
27
  pages: ParsedPackageSource[];
28
28
  snippets: ParsedPackageSource[];
29
- legacySnippets: ParsedPackageSource[];
30
29
  unparsed: (PackageSource & {
31
30
  category: PackageSourceCategory;
32
31
  })[];
@@ -40,7 +39,6 @@ export type ExtractPagePackageIslandsInput = {
40
39
  packageNames: ReadonlySet<string>;
41
40
  packageSnippets: ReadonlySet<string>;
42
41
  variables?: Record<string, string>;
43
- snippetTreeMap?: Record<string, Root>;
44
42
  resolvedTree?: Root;
45
43
  };
46
44
  export type PagePackageIslands = {
@@ -49,7 +47,7 @@ export type PagePackageIslands = {
49
47
  errors: PackageSourceProblem[];
50
48
  };
51
49
  export declare const packageIslandPagePath: (path: string) => string;
52
- export declare const extractPagePackageIslands: ({ path, content, packageNames, packageSnippets, variables, snippetTreeMap, resolvedTree, }: ExtractPagePackageIslandsInput) => PagePackageIslands;
50
+ export declare const extractPagePackageIslands: ({ path, content, packageNames, packageSnippets, variables, resolvedTree, }: ExtractPagePackageIslandsInput) => PagePackageIslands;
53
51
  export type MergedPackageIslands = {
54
52
  islands: IslandSpec[];
55
53
  islandPages: Record<string, string[]>;
@@ -84,7 +84,6 @@ export const classifyPackageSources = (files, { packageNames, variables, normali
84
84
  const result = {
85
85
  pages: [],
86
86
  snippets: [],
87
- legacySnippets: [],
88
87
  unparsed: [],
89
88
  errors: [],
90
89
  };
@@ -96,8 +95,12 @@ export const classifyPackageSources = (files, { packageNames, variables, normali
96
95
  }
97
96
  for (const file of parsed) {
98
97
  const category = categoryOf(file.path);
99
- if (category === 'legacySnippet')
100
- result.legacySnippets.push(file);
98
+ if (category === 'legacySnippet' && usesPackages(file)) {
99
+ result.errors.push({
100
+ file: file.path,
101
+ message: "uses npm package components, which don't work in files included with <Snippet>. Import it into the page instead.",
102
+ });
103
+ }
101
104
  if (category !== 'page' && category !== 'snippet')
102
105
  continue;
103
106
  (category === 'page' ? result.pages : result.snippets).push(file);
@@ -113,11 +116,11 @@ export const classifyPackageSources = (files, { packageNames, variables, normali
113
116
  return result;
114
117
  };
115
118
  export const packageIslandPagePath = (path) => path.replace(/\.mdx?$/, '');
116
- export const extractPagePackageIslands = ({ path, content, packageNames, packageSnippets, variables, snippetTreeMap, resolvedTree, }) => {
119
+ export const extractPagePackageIslands = ({ path, content, packageNames, packageSnippets, variables, resolvedTree, }) => {
117
120
  const options = { packageNames, packageSnippets, pagePath: packageIslandPagePath(path) };
118
121
  let extraction;
119
122
  try {
120
- extraction = getPackageIslandsForContent(Object.assign(Object.assign({}, options), { content, variables, snippetTreeMap }));
123
+ extraction = getPackageIslandsForContent(Object.assign(Object.assign({}, options), { content, variables }));
121
124
  }
122
125
  catch (error) {
123
126
  return {
@@ -14,10 +14,9 @@ export declare class PackageIslandsError extends Error {
14
14
  }
15
15
  export declare const islandPrefixFor: (id: string) => string;
16
16
  export declare const preprocessPageContent: (content: string, variables?: Record<string, string>) => string;
17
- export declare const parsePackageIslands: (processedContent: string, options: ExtractPackageIslandsOptions, snippetTreeMap?: Record<string, Root>) => ExtractPackageIslandsResult;
18
- export declare const getPackageIslandsForContent: ({ content, variables, snippetTreeMap, ...options }: ExtractPackageIslandsOptions & {
17
+ export declare const parsePackageIslands: (processedContent: string, options: ExtractPackageIslandsOptions) => ExtractPackageIslandsResult;
18
+ export declare const getPackageIslandsForContent: ({ content, variables, ...options }: ExtractPackageIslandsOptions & {
19
19
  content: string;
20
20
  variables?: Record<string, string>;
21
- snippetTreeMap?: Record<string, Root>;
22
21
  }) => ExtractPackageIslandsResult;
23
22
  export declare const remarkPackageIslands: (options: RemarkPackageIslandsOptions) => (tree: Root) => void;
@@ -11,8 +11,6 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx, toJs } from 'estree-util-to-js';
13
13
  import { SKIP, visit } from 'unist-util-visit';
14
- import { VFile } from 'vfile';
15
- import { findSnippetCycle, remarkMdxInjectSnippets, } from '../plugins/remark/remarkMdxInjectSnippets.js';
16
14
  import { preprocessCustomHeadingIds } from '../preprocessCustomHeadingIds.js';
17
15
  import { preprocessMdxFragmentCode } from '../preprocessMdxFragmentCode.js';
18
16
  import { coreRemark } from '../remark.js';
@@ -33,21 +31,10 @@ export class PackageIslandsError extends Error {
33
31
  }
34
32
  export const islandPrefixFor = (id) => `mi-${id}-`;
35
33
  export const preprocessPageContent = (content, variables) => preprocessCustomHeadingIds(preprocessMdxFragmentCode(replaceVariables(content, variables)));
36
- export const parsePackageIslands = (processedContent, options, snippetTreeMap) => {
37
- const tree = coreRemark().parse(processedContent);
38
- if (snippetTreeMap) {
39
- const cycle = findSnippetCycle(tree, snippetTreeMap);
40
- if (cycle) {
41
- const message = `<Snippet file="${cycle[0]}"> includes itself (${cycle.join(' -> ')}).`;
42
- return { islands: [], roots: [], errors: [{ message }] };
43
- }
44
- remarkMdxInjectSnippets(snippetTreeMap)(tree, new VFile());
45
- }
46
- return extractPackageIslands(tree, options);
47
- };
34
+ export const parsePackageIslands = (processedContent, options) => extractPackageIslands(coreRemark().parse(processedContent), options);
48
35
  export const getPackageIslandsForContent = (_a) => {
49
- var { content, variables, snippetTreeMap } = _a, options = __rest(_a, ["content", "variables", "snippetTreeMap"]);
50
- return parsePackageIslands(preprocessPageContent(content, variables), options, snippetTreeMap);
36
+ var { content, variables } = _a, options = __rest(_a, ["content", "variables"]);
37
+ return parsePackageIslands(preprocessPageContent(content, variables), options);
51
38
  };
52
39
  const placeholder = (type, id) => ({
53
40
  type,
@@ -19,14 +19,14 @@ import { preprocessMdxFragmentCode } from '../preprocessMdxFragmentCode.js';
19
19
  import { replaceVariables } from '../replaceVariables.js';
20
20
  import { createSnippetTreeMap } from './getMdx/snippets.js';
21
21
  import { getSerializeExtras } from './getSerializeExtras.js';
22
- const getPackageIslandOptions = (packageBuild, pagePath, processedContent, snippetTreeMap) => {
22
+ const getPackageIslandOptions = (packageBuild, pagePath, processedContent) => {
23
23
  const buildBaseUrl = packageBuildBaseUrl(packageBuild.buildId);
24
24
  const options = Object.assign({ packageNames: new Set(packageBuild.packageNames), pagePath }, (packageBuild.packageSnippets && {
25
25
  packageSnippets: new Set(packageBuild.packageSnippets),
26
26
  }));
27
27
  let plan;
28
28
  try {
29
- plan = parsePackageIslands(processedContent, options, snippetTreeMap);
29
+ plan = parsePackageIslands(processedContent, options);
30
30
  }
31
31
  catch (_a) {
32
32
  plan = undefined;
@@ -68,7 +68,7 @@ export function getMdx(_a) {
68
68
  path,
69
69
  };
70
70
  const packageIslands = packageBuild &&
71
- (yield traceFn('getMdx.packageIslands', () => __awaiter(this, void 0, void 0, function* () { return getPackageIslandOptions(packageBuild, path, processedContent, snippetTreeMap); })));
71
+ (yield traceFn('getMdx.packageIslands', () => __awaiter(this, void 0, void 0, function* () { return getPackageIslandOptions(packageBuild, path, processedContent); })));
72
72
  if (packageBuild)
73
73
  allowedComponents = [...allowedComponents, MINT_ISLAND_COMPONENT];
74
74
  const planErrors = (_c = (_b = packageIslands === null || packageIslands === void 0 ? void 0 : packageIslands.plan) === null || _b === void 0 ? void 0 : _b.errors) !== null && _c !== void 0 ? _c : [];
@@ -1,5 +1,4 @@
1
1
  export { createSnippetTreeMap, getMdx, type GetMdxType, type PackageBuildInput, type Snippet, } from './getMdx.js';
2
2
  export { getSerializeExtras } from './getSerializeExtras.js';
3
- export { createPackageSnippetTreeMap } from './package-snippet-tree-map.js';
4
3
  export { compileWithPackageBuildFallback } from '../islands/package-build-fallback.js';
5
4
  export { compilePackageBuild, packageBuildBaseUrl, packageBuildIdFromBaseUrl, packagePageBaseUrl, packagePageStylesheets, withPackageGlobalStylesheets, } from '../islands/package-page-url.js';
@@ -1,5 +1,4 @@
1
1
  export { createSnippetTreeMap, getMdx, } from './getMdx.js';
2
2
  export { getSerializeExtras } from './getSerializeExtras.js';
3
- export { createPackageSnippetTreeMap } from './package-snippet-tree-map.js';
4
3
  export { compileWithPackageBuildFallback } from '../islands/package-build-fallback.js';
5
4
  export { compilePackageBuild, packageBuildBaseUrl, packageBuildIdFromBaseUrl, packagePageBaseUrl, packagePageStylesheets, withPackageGlobalStylesheets, } from '../islands/package-page-url.js';