@mintlify/common 1.0.1254 → 1.0.1256

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.
@@ -20,7 +20,7 @@ export const extractPackageIslands = (tree, options) => {
20
20
  return [];
21
21
  return [...sideEffects].map(([source, line]) => {
22
22
  const message = CSS_SPECIFIER.test(source)
23
- ? `"${source}" is imported on a page without package components, so it never loads. List it in packages.css in docs.json to load it on every page and remove this import, or use a package component on this page.`
23
+ ? `"${source}" is imported on a page without package components, so it never loads. Use a package component on this page or remove this import.`
24
24
  : `"${source}" is imported on a page without package components, so it never runs. Use a package component on this page or remove this import.`;
25
25
  return { line, code: 'side-effect-import-without-island', message };
26
26
  });
@@ -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';