style: apply code formatting to core files

- Format comic-book.js, epub.js, and view.js with consistent style
- No functional changes, formatting only
This commit is contained in:
2026-04-16 20:04:05 -04:00
parent 15165d8fb1
commit 82142f8960
3 changed files with 1821 additions and 1567 deletions
+52 -34
View File
@@ -1,45 +1,63 @@
export const makeComicBook = ({ entries, loadBlob, getSize }, file) => { export const makeComicBook = ({ entries, loadBlob, getSize }, file) => {
const cache = new Map() const cache = new Map();
const urls = new Map() const urls = new Map();
const load = async name => { const load = async (name) => {
if (cache.has(name)) return cache.get(name) if (cache.has(name)) return cache.get(name);
const src = URL.createObjectURL(await loadBlob(name)) const src = URL.createObjectURL(await loadBlob(name));
const page = URL.createObjectURL( const page = URL.createObjectURL(
new Blob([`<!DOCTYPE html><html><head><meta charset="utf-8"></head><body style="margin: 0"><img src="${src}"></body></html>`], { type: 'text/html' })) new Blob(
urls.set(name, [src, page]) [
cache.set(name, page) `<!DOCTYPE html><html><head><meta charset="utf-8"></head><body style="margin: 0"><img src="${src}"></body></html>`,
return page ],
} { type: "text/html" },
const unload = name => { ),
urls.get(name)?.forEach?.(url => URL.revokeObjectURL(url)) );
urls.delete(name) urls.set(name, [src, page]);
cache.delete(name) cache.set(name, page);
} return page;
};
const unload = (name) => {
urls.get(name)?.forEach?.((url) => URL.revokeObjectURL(url));
urls.delete(name);
cache.delete(name);
};
const exts = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg', '.jxl', '.avif'] const exts = [
".jpg",
".jpeg",
".png",
".gif",
".bmp",
".webp",
".svg",
".jxl",
".avif",
];
const files = entries const files = entries
.map(entry => entry.filename) .map((entry) => entry.filename)
.filter(name => exts.some(ext => name.endsWith(ext))) .filter((name) => exts.some((ext) => name.endsWith(ext)))
.sort(new Intl.Collator([], { numeric: true }).compare) .sort(new Intl.Collator([], { numeric: true }).compare);
if (!files.length) throw new Error('No supported image files in archive') if (!files.length) throw new Error("No supported image files in archive");
const book = {} const book = {};
book.getCover = () => loadBlob(files[0]) book.getCover = () => loadBlob(files[0]);
book.metadata = { title: file.name } book.metadata = { title: file.name };
book.sections = files.map(name => ({ book.sections = files.map((name) => ({
id: name, id: name,
load: () => load(name), load: () => load(name),
unload: () => unload(name), unload: () => unload(name),
size: getSize(name), size: getSize(name),
})) }));
book.toc = files.map(name => ({ label: name, href: name })) book.toc = files.map((name) => ({ label: name, href: name }));
book.rendition = { layout: 'pre-paginated' } book.rendition = { layout: "pre-paginated" };
book.resolveHref = href => ({ index: book.sections.findIndex(s => s.id === href) }) book.resolveHref = (href) => ({
book.splitTOCHref = href => [href, null] index: book.sections.findIndex((s) => s.id === href),
book.getTOCFragment = doc => doc.documentElement });
book.splitTOCHref = (href) => [href, null];
book.getTOCFragment = (doc) => doc.documentElement;
book.destroy = () => { book.destroy = () => {
for (const arr of urls.values()) for (const arr of urls.values())
for (const url of arr) URL.revokeObjectURL(url) for (const url of arr) URL.revokeObjectURL(url);
} };
return book return book;
} };
+870 -706
View File
File diff suppressed because it is too large Load Diff
+475 -403
View File
File diff suppressed because it is too large Load Diff