@mintlify/common 1.0.1248 → 1.0.1249
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.
- package/dist/mdx/islands/package-build-fallback.d.ts +3 -0
- package/dist/mdx/islands/package-build-fallback.js +28 -0
- package/dist/mdx/islands/package-page-url.d.ts +11 -0
- package/dist/mdx/islands/package-page-url.js +20 -0
- package/dist/mdx/server-only/index.d.ts +2 -1
- package/dist/mdx/server-only/index.js +2 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
export function compileWithPackageBuildFallback(compile, onPackageBuildFailure) {
|
|
11
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
+
let compiled;
|
|
13
|
+
try {
|
|
14
|
+
compiled = yield compile(true);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
yield onPackageBuildFailure(error);
|
|
18
|
+
return compile(false);
|
|
19
|
+
}
|
|
20
|
+
if (!compiled.parseFailed)
|
|
21
|
+
return compiled;
|
|
22
|
+
const withoutPackageBuild = yield compile(false);
|
|
23
|
+
if (withoutPackageBuild.parseFailed)
|
|
24
|
+
return compiled;
|
|
25
|
+
yield onPackageBuildFailure(new Error('Page failed to compile with its package build'));
|
|
26
|
+
return withoutPackageBuild;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -9,3 +9,14 @@ export declare function packagePageStylesheets(baseUrl: string, pagePath: string
|
|
|
9
9
|
}[];
|
|
10
10
|
}>>;
|
|
11
11
|
}): string[];
|
|
12
|
+
export declare function compilePackageBuild<T extends {
|
|
13
|
+
islands: Readonly<Record<string, unknown>>;
|
|
14
|
+
}>(packageBuild: T | undefined): T | undefined;
|
|
15
|
+
export declare function withPackageGlobalStylesheets<T extends {
|
|
16
|
+
packageCssFiles?: string[];
|
|
17
|
+
}>(mdxExtracts: T, packageBuild: {
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
css?: readonly {
|
|
20
|
+
path: string;
|
|
21
|
+
}[];
|
|
22
|
+
} | undefined, pagePath: string): T;
|
|
@@ -32,3 +32,23 @@ export function packagePageStylesheets(baseUrl, pagePath, islandIds, manifest) {
|
|
|
32
32
|
}
|
|
33
33
|
return [...paths].map((path) => `${pageBaseUrl}/${path}`);
|
|
34
34
|
}
|
|
35
|
+
export function compilePackageBuild(packageBuild) {
|
|
36
|
+
return packageBuild && Object.keys(packageBuild.islands).length > 0 ? packageBuild : undefined;
|
|
37
|
+
}
|
|
38
|
+
export function withPackageGlobalStylesheets(mdxExtracts, packageBuild, pagePath) {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if (!((_a = packageBuild === null || packageBuild === void 0 ? void 0 : packageBuild.css) === null || _a === void 0 ? void 0 : _a.length))
|
|
41
|
+
return mdxExtracts;
|
|
42
|
+
let globalFiles;
|
|
43
|
+
try {
|
|
44
|
+
globalFiles = packagePageStylesheets(packageBuild.baseUrl, pagePath, [], {
|
|
45
|
+
css: packageBuild.css,
|
|
46
|
+
islands: {},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (_c) {
|
|
50
|
+
return mdxExtracts;
|
|
51
|
+
}
|
|
52
|
+
const packageCssFiles = [...new Set([...globalFiles, ...((_b = mdxExtracts.packageCssFiles) !== null && _b !== void 0 ? _b : [])])];
|
|
53
|
+
return Object.assign(Object.assign({}, mdxExtracts), { packageCssFiles });
|
|
54
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createSnippetTreeMap, getMdx, type GetMdxType, type PackageBuildInput, type Snippet, } from './getMdx.js';
|
|
2
2
|
export { getSerializeExtras } from './getSerializeExtras.js';
|
|
3
3
|
export { createPackageSnippetTreeMap } from './package-snippet-tree-map.js';
|
|
4
|
-
export {
|
|
4
|
+
export { compileWithPackageBuildFallback } from '../islands/package-build-fallback.js';
|
|
5
|
+
export { compilePackageBuild, packagePageBaseUrl, packagePageStylesheets, withPackageGlobalStylesheets, } from '../islands/package-page-url.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createSnippetTreeMap, getMdx, } from './getMdx.js';
|
|
2
2
|
export { getSerializeExtras } from './getSerializeExtras.js';
|
|
3
3
|
export { createPackageSnippetTreeMap } from './package-snippet-tree-map.js';
|
|
4
|
-
export {
|
|
4
|
+
export { compileWithPackageBuildFallback } from '../islands/package-build-fallback.js';
|
|
5
|
+
export { compilePackageBuild, packagePageBaseUrl, packagePageStylesheets, withPackageGlobalStylesheets, } from '../islands/package-page-url.js';
|