import type { CustomFontFamily, CustomFontFormat, Resource } from '../types.js'; import type { BundleChapterSpec, BundleFontFamilySpec, BitmapInfo, BundleImageSize, BundleLocaleOverrides, BundleManifest, BundleManifestV1, BundleResourceSpec, BundleStart, BundleViewSpec } from './types.js'; /** The optional showcase fields: wrong types reject the manifest rather * than being silently dropped. */ export declare function hasValidShowcaseMeta(v: Record): boolean; /** True when `data` is a valid `preset.json`, version 1 (`markdown`) or 2 * (`chapters`). */ export declare function isBundleManifest(data: unknown): data is BundleManifest; /** Which markdown file a version 1 manifest serves for `locale`. */ export declare function pickMarkdownFile(manifest: BundleManifestV1, locale: string): string; /** The per-locale overrides that apply to `locale`, or null when the * manifest has none: those of the locale the content is served under (see * {@link resolveBundleLocale}), so text and wording never disagree. That * is the entry of the exact tag; for any locale but the manifest's own, * else the entry `matchContentLocale` picks: its bare base language (`pt` * for `pt-BR`), else a regional variant of the same language, and for * Chinese only an entry in the same script. The manifest's own locale is * what the shared wording is written in: only an entry naming it exactly * rewords it, never a sibling variant (`pt-BR` when the bundle is * `pt-PT`). */ export declare function pickLocaleOverrides(manifest: BundleManifest, locale: string): BundleLocaleOverrides | null; /** What {@link pickBundleMeta} reads: a manifest, or an index entry that * carries its names (`name`, `description`, `locale`, `localized`). */ export type BundleNames = Pick & { localized?: Record>; }; /** The name and description of the edition served for `locale`: the * manifest's, with that language's `localized[…].name` and * `description` over them (#891). An empty localized name keeps the * manifest's. Given an index entry rather than a manifest, the edition is * picked among the manifest's locale and the localized keys. */ export declare function pickBundleMeta(manifest: BundleManifest | BundleNames, locale: string): { name: string; description?: string; }; /** How the edition served for `locale` opens: the manifest's `view` with * that language's `localized[…].view` over it. */ export declare function pickBundleView(manifest: BundleManifest, locale: string): BundleViewSpec | undefined; /** * Where a book starts ({@link BundleStart}), as a manifest or a caller * gives it, in the shape the engine takes as a `continuation`: the fields * it knows, each of the right type, the heading counters complete. A field * of another type is left out rather than failing the bundle, and so is * `bookPageCount`. Undefined when nothing is left: a book that starts at * its own beginning. */ export declare function bundleStart(value: unknown): BundleStart | undefined; /** Where the edition served for `locale` starts: that language's * `localized[…].start`, else the manifest's `start`; undefined for a book * that starts at its own beginning. */ export declare function pickBundleStart(manifest: BundleManifest, locale: string): BundleStart | undefined; /** The locale a bundle actually serves for `locale`: the key of its * chapter map when the content is a locale map, the key whose wording it * reads when shared chapters carry `localized` wording, else the * manifest's own locale, else `locale` itself. */ export declare function resolveBundleLocale(manifest: BundleManifest, locale: string): string; /** The language a bundle's default configuration is localised to (the * names of the built-in resource types: "Figure", "Figura"), read for * `locale`. When the manifest names its languages, the one its content is * served in ({@link resolveBundleLocale}); when it names none, the * document language of its own `config` (`locale`, then * `bodyText.hyphenation.locale`), as the engine resolves it; else * `locale`. */ export declare function resolveBundleConfigLocale(manifest: BundleManifest, locale: string): string; /** The chapter files to read for `locale`: a version 1 manifest yields a * single untitled chapter. */ export declare function pickChapterSpecs(manifest: BundleManifest, locale: string): BundleChapterSpec[]; /** Lowercase, hyphen-separated slug: diacritics stripped, letters and * digits of every script kept (`第一回-甄士隐梦幻识通灵`, #181), runs of * anything else collapsed to one hyphen. '' for symbol-only input. */ export declare function slugify(input: string): string; /** `candidate`, or `candidate-2`, `-3`, … when `taken` has it; a blank * candidate falls back to `fallback`. */ export declare function uniqueSlug(candidate: string, taken: Set, fallback?: string): string; /** `chapters/01-intro.md`: zero-padded ordinal (at least two digits) plus a * slug of the title, unique against `taken` (which it extends). */ export declare function chapterFileName(index: number, title: string, taken: Set, count?: number): string; export declare function fileExtension(file: string): string; export declare function fileBasename(file: string): string; /** Media type of a bundle file, from its extension. */ export declare function mimeForFile(file: string): string; /** True when `file` is a bitmap the engine can place. */ export declare function isBitmapFile(file: string): boolean; /** True when `file` is a video a bundle carries (#454). */ export declare function isVideoFile(file: string): boolean; /** The bitmap format of a picture file (`png`, `jpeg`…), or undefined. */ export declare function bitmapFormatOf(file: string): string | undefined; export declare function isSvgFile(file: string): boolean; export declare function isPdfFile(file: string): boolean; /** Font format of a file name, or null when it is not a font. */ export declare function fontFormatFromFile(file: string): CustomFontFormat | null; /** File extension to write an image of this media type under, or null when * it is not a picture a bundle takes (a cover thumbnail). */ export declare function extensionForImageMime(mime: string): string | null; /** File extension to write a resource's bytes under, or null for resources * without a file (tables). */ export declare function extensionForResource(r: Resource): string | null; /** File extension of a self-hosted video's file (`mp4`, `webm`…). */ export declare function extensionForVideo(format: string | undefined): string; /** File extension of a bitmap format (`jpeg` → `jpg`). */ export declare function extensionForBitmapFormat(format: string): string; export interface BundleFontFiles { families: CustomFontFamily[]; files: { fileId: string; fileName: string; format: CustomFontFormat; file: string; family: string; weight: number; style: 'normal' | 'italic'; }[]; warnings: string[]; } /** Turn manifest font families into `config.customFonts` entries plus the * list of files to read. `.woff` is not supported by the PDF backend and * is skipped with a warning, as is any unrecognised extension. */ export declare function fontsToCustomFonts(fonts: BundleFontFamilySpec[], fileIdFor?: (file: string) => string): BundleFontFiles; /** Build an engine `Resource` from a manifest entry. `size` supplies the * intrinsic dimensions when the spec omits them, and a bitmap's file * resolution when the spec gives no `fileResolution`. Bitmap/SVG kind is * derived from the file extension. */ export declare function resourceFromSpec(spec: BundleResourceSpec, size?: BundleImageSize, fileIdFor?: (file: string) => string): Resource; /** An SVG's intrinsic pixel size from its root element: explicit * `width`/`height`, else the `viewBox` extent; undefined when neither * gives one. Reads the markup textually, so it runs anywhere. */ export declare function svgSize(markup: string): BundleImageSize | undefined; /** A bitmap's pixel size read from its header (PNG, JPEG, GIF, WebP), or * undefined when the header is not recognised. */ export declare function bitmapSize(bytes: ArrayBuffer | Uint8Array): BundleImageSize | undefined; /** A bitmap's pixel size and, when the file states one, its resolution * (#631): PNG `pHYs` in pixels per metre (unit 0, an aspect ratio only, * is ignored); JPEG JFIF density (dpi or dots per cm; units 0 ignored) and * EXIF `XResolution` / `YResolution`, EXIF winning when both are there * (Photoshop writes both and edits the EXIF one); WebP EXIF. GIF carries * none. The value is returned as read: 72 or 96 ppi often means "no * information" (see `layout.bitmapResolution: 'file'`). Undefined when the * header is not recognised. */ export declare function bitmapInfo(bytes: ArrayBuffer | Uint8Array): BitmapInfo | undefined; //# sourceMappingURL=manifest.d.ts.map