myst-cli
Version:
Command line tools for MyST
97 lines • 4.44 kB
TypeScript
import type { GenericParent } from 'myst-common';
import type { VFileMessage } from 'vfile-message';
import type { PageFrontmatter } from 'myst-frontmatter';
import type { ISession } from '../session/types.js';
import { ImageExtensions } from '../utils/resolveExtension.js';
export declare const BASE64_HEADER_SPLIT = ";base64,";
export declare function downloadAndSaveImage(session: ISession, url: string, file: string, fileFolder: string): Promise<string | undefined>;
export declare function resolveOutputPath(file: string, writeFolder: string, altOutputFolder?: string): string;
export declare function saveImageInStaticFolder(session: ISession, urlSource: string, sourceFile: string, writeFolder: string, opts?: {
altOutputFolder?: string;
position?: VFileMessage['position'];
}): Promise<{
urlSource: string;
url: string;
} | null>;
export declare function transformImagesToEmbed(mdast: GenericParent): void;
export declare function transformImagesWithoutExt(session: ISession, mdast: GenericParent, file: string, opts?: {
imageExtensions?: ImageExtensions[];
}): void;
export declare function transformImagesToDisk(session: ISession, mdast: GenericParent, file: string, writeFolder: string, opts?: {
altOutputFolder?: string;
imageExtensions?: ImageExtensions[];
}): Promise<void>;
type ConversionOpts = {
file: string;
inkscapeAvailable: boolean;
imagemagickAvailable: boolean;
dwebpAvailable: boolean;
ffmpegAvailable: boolean;
};
type ConversionFn = (session: ISession, source: string, writeFolder: string, conversionOpts: ConversionOpts) => Promise<string | null>;
/**
* Returns a list of all available conversion functions from the input extension to valid extensions
*
* If multiple functions are available, they are ordered based on the order of validExts.
* Therefore validExts should have preferred formats first.
*/
export declare function getConversionFns(imageExt: string, validExts: ImageExtensions[]): ConversionFn[];
/**
* Transform to convert all images with known-but-unsupported extensions to supported extensions
*
* The `imageExtensions` option is a list of supported extensions, ordered by preference.
* For example you may use `imageExtensions = ['.svg', '.png']` so the vector svg
* format is preferred but fallback png is allowed.
*
* If an image extension is unknown or if there are no functions to covnert it to
* a valid extension, the image will remain unchanged.
*/
export declare function transformImageFormats(session: ISession, mdast: GenericParent, file: string, writeFolder: string, opts?: {
altOutputFolder?: string;
imageExtensions?: ImageExtensions[];
}): Promise<void[] | undefined>;
export declare function transformThumbnail(session: ISession, mdast: GenericParent | null, file: string, frontmatter: PageFrontmatter, writeFolder: string, opts?: {
altOutputFolder?: string;
webp?: boolean;
maxSizeWebp?: number;
}): Promise<{
url: string;
urlOptimized?: string;
} | undefined>;
export declare function transformBanner(session: ISession, file: string, frontmatter: {
banner?: string | null;
bannerOptimized?: string;
}, writeFolder: string, opts?: {
altOutputFolder?: string;
webp?: boolean;
maxSizeWebp?: number;
}): Promise<{
url: string;
urlOptimized?: string;
} | undefined>;
export declare function transformWebp(session: ISession, opts: {
file: string;
imageWriteFolder: string;
maxSizeWebp?: number;
}): Promise<void>;
/**
* Handle placeholder image nodes in figures.
*
* This reduces figures to a single representation; it should only be used for static contexts
* where you do not need to persist the multiple figure representations.
*
* If there is a valid image or code node in the figure, the placeholder image is removed.
* If there is no other valid image or code node, the placeholder image is promoted to normal image.
*
* Elsewhere in the mdast tree, placeholder images are just left as-is; currently the only way to
* author a placeholder image is using a figure directive.
*/
export declare function transformPlaceholderImages(mdast: GenericParent, opts?: {
imageExtensions?: ImageExtensions[];
}): void;
/**
* Trim base64 values for urlSource when they have been replaced by image urls
*/
export declare function transformDeleteBase64UrlSource(mdast: GenericParent): Promise<void[]>;
export {};
//# sourceMappingURL=images.d.ts.map