Something went wrong. Try again.
Something went wrong. Try again.
1.8 kB · 35 lines
JavaScript
at main
123456789101112131415161718192021222324252627282930313233343536// Ported verbatim from FilesPage.html lines 3288-3308 and 3808.// The mutable `let` settings block (3312-3321) is intentionally dropped —// replaced by a frozen `opts` object threaded from cli.js.
/** Device profiles (short edge x long edge in portrait orientation). */export const DEVICE_PROFILES = { X4: { width: 480, height: 800, label: 'X4' }, X3: { width: 528, height: 792, label: 'X3' },};
// Default conversion settingsexport const DEFAULT_DEVICE = 'X4';export const DEFAULT_MAX_WIDTH = DEVICE_PROFILES[DEFAULT_DEVICE].width;export const DEFAULT_MAX_HEIGHT = DEVICE_PROFILES[DEFAULT_DEVICE].height;export const DEFAULT_JPEG_QUALITY = 85;export const DEFAULT_ENABLE_GRAYSCALE = true;export const DEFAULT_ENABLE_AUTO_CROP = false;// Auto-crop is opt-in because sparse title/logo pages can be zoomed aggressively.export const CROP_WHITE_THRESHOLD = 245;export const CROP_BACKGROUND_TOLERANCE = 28;export const CROP_BACKGROUND_MAX_SPREAD = 24;export const CROP_EDGE_SAMPLE_SIZE = 12;export const CROP_PADDING_PX = 8;export const MIN_CROP_SAVINGS_RATIO = 0.08;export const MIN_COLOR_CROP_SAVINGS_RATIO = 0.20;export const MIN_CROP_DIMENSION = 240;
/** Defensive CSS injected into every XHTML <head> — prevents e-ink overflow. (source line 3808) */export const DEFENSIVE_STYLE = '<style type="text/css">img,svg{max-width:100%;height:auto}body{overflow-wrap:break-word}table{max-width:100%;table-layout:fixed}pre,code{white-space:pre-wrap;word-wrap:break-word}*{box-sizing:border-box}</style>';
/** Namespace constants used by the port sites. */export const OPF_NS = 'http://www.idpf.org/2007/opf';export const SVG_NS = 'http://www.w3.org/2000/svg';export const XLINK_NS = 'http://www.w3.org/1999/xlink';export const XHTML_NS = 'http://www.w3.org/1999/xhtml';