@@ -83,39 +83,46 @@ export const makeBook = async file => {
8383 const loader = await makeDirectoryLoader ( file )
8484 const { EPUB } = await import ( './epub.js' )
8585 book = await new EPUB ( loader ) . init ( )
86+ book . type = 'epub' ;
8687 }
8788 else if ( ! file . size ) throw new NotFoundError ( 'File not found' )
8889 else if ( await isZip ( file ) ) {
8990 const loader = await makeZipLoader ( file )
9091 if ( isCBZ ( file ) ) {
9192 const { makeComicBook } = await import ( './comic-book.js' )
9293 book = makeComicBook ( loader , file )
94+ book . type = 'comic-book' ;
9395 }
9496 else if ( isFBZ ( file ) ) {
9597 const { makeFB2 } = await import ( './fb2.js' )
9698 const { entries } = loader
9799 const entry = entries . find ( entry => entry . filename . endsWith ( '.fb2' ) )
98100 const blob = await loader . loadBlob ( ( entry ?? entries [ 0 ] ) . filename )
99101 book = await makeFB2 ( blob )
102+ book . type = 'fb2' ;
100103 }
101104 else {
102105 const { EPUB } = await import ( './epub.js' )
103106 book = await new EPUB ( loader ) . init ( )
107+ book . type = 'epub' ;
104108 }
105109 }
106110 else if ( await isPDF ( file ) ) {
107111 const { makePDF } = await import ( './pdf.js' )
108112 book = await makePDF ( file )
113+ book . type = 'pdf'
109114 }
110115 else {
111116 const { isMOBI, MOBI } = await import ( './mobi.js' )
112117 if ( await isMOBI ( file ) ) {
113118 const fflate = await import ( './vendor/fflate.js' )
114119 book = await new MOBI ( { unzlib : fflate . unzlibSync } ) . open ( file )
120+ book . type = 'mobi' ;
115121 }
116122 else if ( isFB2 ( file ) ) {
117123 const { makeFB2 } = await import ( './fb2.js' )
118124 book = await makeFB2 ( file )
125+ book . type = 'fb2' ;
119126 }
120127 }
121128 if ( ! book ) throw new UnsupportedTypeError ( 'File type not supported' )
0 commit comments