UNPKG

mwoffliner

Version:
133 lines (132 loc) 3.98 kB
import { Dump } from '../Dump.js'; type renderType = 'auto' | 'desktop' | 'mobile' | 'specific'; export type renderName = 'VisualEditor' | 'WikimediaDesktop' | 'WikimediaMobile' | 'RestApi' | 'ActionParse'; interface RendererBuilderOptionsBase { renderType: renderType; } interface RendererBuilderOptionsCommon { renderType: renderType; renderName?: never; } interface RendererBuilderOptionsSpecific extends RendererBuilderOptionsBase { renderType: 'specific'; renderName: renderName; } export type RendererBuilderOptions = RendererBuilderOptionsCommon | RendererBuilderOptionsSpecific; export interface DownloadOpts { articleId: string; articleUrl: string; articleDetail: ArticleDetail; } export interface Redirect { from: string; to: string; } export interface DownloadRes { data?: any; moduleDependencies: any; redirects: Redirect[]; displayTitle?: string; articleSubtitle?: string; bodyCssClass?: string; htmlCssClass?: string; } export interface RenderOptsModules { jsConfigVars: string; jsDependenciesList: string[]; styleDependenciesList: string[]; } export interface RenderOpts { data?: any; moduleDependencies: RenderOptsModules; articleId?: string; articleDetailXId?: RKVS<ArticleDetail>; articleDetail?: ArticleDetail; displayTitle?: string; articleSubtitle?: string; bodyCssClass?: string; htmlCssClass?: string; dump: Dump; } export interface ProcessHtmlOpts { html: string; dump: Dump; articleId: string; articleDetail: any; displayTitle?: string; articleSubtitle?: string; moduleDependencies: any; callback: any; } export interface RenderSingleOutput { articleId: string; displayTitle: string; html: string; imageDependencies: any; videoDependencies: any; mediaDependencies: any; moduleDependencies: any; staticFiles: string[]; subtitles: any; } export type RenderOutput = RenderSingleOutput[]; export declare abstract class Renderer { staticFilesListCommon: string[]; constructor(); protected treatAudioVideo(dump: Dump, srcCache: KVS<boolean>, articleId: string, audioVideoEl: DominoElement): Promise<{ imageDependencies: string[]; videoDependencies: string[]; subtitles: string[]; }>; private adjustVideoElementAttributes; private chooseBestVideoSource; private chooseBestAudioSource; private handleVideoPoster; private updateAudioVideoSrc; protected treatSubtitle(trackEle: DominoElement, articleId: string): Promise<string>; private treatImageFrames; private treatImage; private shouldKeepImage; protected treatMedias(parsoidDoc: DominoElement, dump: Dump, articleId: string): Promise<{ doc: any; imageDependencies: string[]; videoDependencies: string[]; subtitles: string[]; }>; private isStillLinked; private shouldKeepNode; private makeThumbDiv; processHtml(processHtmlOpts: ProcessHtmlOpts): Promise<{ finalHTML: string; mediaDependencies: { url: string; path: string; }[]; imageDependencies: { url: string; path: string; }[]; videoDependencies: { url: string; path: string; }[]; subtitles: { url: string; path: string; }[]; }>; private mergeTemplateDoc; private addNoIndexCommentToElement; private removeIframeTags; private removeCitations; private clearLinkAndInputTags; private clearNodes; private applyOtherTreatments; /** * Add an H1 tag with page title on top of article except main page */ protected injectH1TitleToHtml(content: string, articleDetail: any): string; abstract download(downloadOpts: DownloadOpts): Promise<DownloadRes>; abstract render(renderOpts: RenderOpts): Promise<any>; } export {};