Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
js:foliate-js:reader [2024/03/26 13:23] – avillepreux | js:foliate-js:reader [2024/03/26 13:52] (Version actuelle) – ancienne révision (2024/03/26 13:27) restaurée avillepreux | ||
---|---|---|---|
Ligne 20: | Ligne 20: | ||
const makeZipLoader = async file => { | const makeZipLoader = async file => { | ||
const { configure, ZipReader, BlobReader, TextWriter, BlobWriter } = | const { configure, ZipReader, BlobReader, TextWriter, BlobWriter } = | ||
- | await import(' | + | await import(' |
configure({ useWebWorkers: | configure({ useWebWorkers: | ||
const reader = new ZipReader(new BlobReader(file)) | const reader = new ZipReader(new BlobReader(file)) | ||
Ligne 70: | Ligne 70: | ||
if (file.isDirectory) { | if (file.isDirectory) { | ||
const loader = await makeDirectoryLoader(file) | const loader = await makeDirectoryLoader(file) | ||
- | const { EPUB } = await import(' | + | const { EPUB } = await import(' |
book = await new EPUB(loader).init() | book = await new EPUB(loader).init() | ||
} | } | ||
Ligne 77: | Ligne 77: | ||
const loader = await makeZipLoader(file) | const loader = await makeZipLoader(file) | ||
if (isCBZ(file)) { | if (isCBZ(file)) { | ||
- | const { makeComicBook } = await import(' | + | const { makeComicBook } = await import(' |
book = makeComicBook(loader, | book = makeComicBook(loader, | ||
} else if (isFBZ(file)) { | } else if (isFBZ(file)) { | ||
- | const { makeFB2 } = await import(' | + | const { makeFB2 } = await import(' |
const { entries } = loader | const { entries } = loader | ||
const entry = entries.find(entry => entry.filename.endsWith(' | const entry = entries.find(entry => entry.filename.endsWith(' | ||
Ligne 86: | Ligne 86: | ||
book = await makeFB2(blob) | book = await makeFB2(blob) | ||
} else { | } else { | ||
- | const { EPUB } = await import(' | + | const { EPUB } = await import(' |
book = await new EPUB(loader).init() | book = await new EPUB(loader).init() | ||
} | } | ||
} | } | ||
else if (await isPDF(file)) { | else if (await isPDF(file)) { | ||
- | const { makePDF } = await import(' | + | const { makePDF } = await import(' |
book = await makePDF(file) | book = await makePDF(file) | ||
} | } | ||
else { | else { | ||
- | const { isMOBI, MOBI } = await import(' | + | const { isMOBI, MOBI } = await import(' |
if (await isMOBI(file)) { | if (await isMOBI(file)) { | ||
- | const fflate = await import(' | + | const fflate = await import(' |
book = await new MOBI({ unzlib: fflate.unzlibSync }).open(file) | book = await new MOBI({ unzlib: fflate.unzlibSync }).open(file) | ||
} else if (isFB2(file)) { | } else if (isFB2(file)) { | ||
- | const { makeFB2 } = await import(' | + | const { makeFB2 } = await import(' |
book = await makeFB2(file) | book = await makeFB2(file) | ||
} | } |