mwoffliner
Version:
MediaWiki ZIM scraper
74 lines (73 loc) • 4.38 kB
TypeScript
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import Downloader from '../Downloader.js';
import fs from 'fs';
import { ZimCreator } from '@openzim/libzim';
import { Config } from '../config.js';
import { AxiosError } from 'axios';
export declare function isValidEmail(email: string): boolean;
export declare function lcFirst(str: string): string;
export declare function ucFirst(str: string): string;
declare function _decodeURIComponent(uri: string): string;
export { _decodeURIComponent as decodeURIComponent };
export declare function touch(paths: string[] | string): void;
export declare function getFullUrl(url: string, baseUrl: URL | string): string;
export declare function getSizeFromUrl(url: string): {
mult: any;
width: any;
};
export declare function randomString(len: number): string;
export declare function mkdirPromise(path: string): any;
export declare function writeFilePromise(path: string, content: string | Buffer, encoding?: fs.EncodingOption): Promise<unknown>;
export declare function readFilePromise(path: string, encoding?: fs.EncodingOption): Promise<string | Buffer>;
export declare function contains(arr: any[], value: any): boolean;
export declare function migrateChildren(from: any, to: any, beforeNode: any): void;
export declare function getStringsForLang(language: string, fallbackLanguage?: string): {
[id: string]: string;
};
export declare function interpolateTranslationString(str: string, parameters: {
[key: string]: string;
}): string;
export declare function saveStaticFiles(staticFiles: Set<string>, zimCreator: ZimCreator): Promise<void>;
export declare function getStaticFiles(jsStaticFiles: string[], cssStaticFiles: string[]): string[];
export declare function cssPath(css: string, subDirectory?: string): string;
export declare function jsPath(js: string, subDirectory?: string): string;
export declare function genHeaderCSSLink(config: Config, css: string, articleId: string, subDirectory?: string): string;
export declare function genHeaderScript(config: Config, js: string, articleId: string, subDirectory?: string, attributes?: string): string;
export declare function genCanonicalLink(config: Config, webUrl: string, articleId: string): string;
export declare function getDumps(format: boolean | boolean[]): any[];
export declare function getIso3(langIso2: string): Promise<string>;
export declare function getMediaBase(url: string, escape: boolean): any;
/**
* This function extracts the title from an HTML string and returns it stripped of any HTML tags.
*
* @param {string} html - The `html` parameter is a string that represents an HTML document. The
* function extracts the title of the document from this HTML string.
*
* @returns a string that represents the title of an HTML document with all HTML tags removed. If the
* title cannot be found in the input HTML string, an empty string is returned.
*/
export declare function getStrippedTitleFromHtml(html: string): string;
export declare function zip(...args: any[][]): any[][];
export declare function deDup<T>(_arr: T[], getter: (o: T) => any): T[];
export declare function getRelativeFilePath(parentArticleId: string, fileBase: string, resourceNamespace: 'I' | 'A' | 'M' | '-'): string;
export declare function normalizeModule(path: string): string;
export declare function isNodeModule(path: string): boolean;
export declare function objToQueryString(obj: KVS<any>): string;
export declare function sanitizeString(str: string): string;
export declare function encodeArticleIdForZimHtmlUrl(articleId: string): string;
export declare function ensureTrailingChar(input: string, trailingChar: string): string;
export declare function stripHttpFromUrl(url: string): string;
export declare function isImageMimeType(mimeType: string): boolean;
export declare function isBitmapImageMimeType(mimeType: string): boolean;
export declare function isWebpCandidateImageMimeType(content_type: string): boolean;
export declare function cleanupAxiosError(err: AxiosError): {
name: string;
message: string;
url: string;
status: number;
responseType: import("axios").ResponseType;
data: unknown;
};
export declare function extractArticleList(articleList: string, downloader: Downloader): Promise<string[]>;
export declare function getTmpDirectory(): Promise<string>;