readium / readium-js-viewer

👁 ReadiumJS viewer: default web app for Readium.js library
BSD 3-Clause "New" or "Revised" License
551 stars 186 forks source link

creating blob in the readium (because of this ,facning data migration) #747

Open mohan9000 opened 3 years ago

mohan9000 commented 3 years ago

hi , we have found that there is blob creation in the readium library and assigning that value to the iframe src , and for the data-src assigning differently is there any particular reason for doing that, please consider this one as priority

mohan9000 commented 3 years ago
example

please find this attachment

mohan9000 commented 3 years ago

in the above attachment there are two different values for the src and data-src

danielweck commented 3 years ago

Blobs URI are used when some pre-processing is required on EPUB resources, or when the EPUB container itself is zipped instead of "exploded" (i.e. unzipped). For example, drag-and-dropping an EPUB file onto the web/cloud reader triggers a code path that stores the EPUB in memory, and extracts / inflates resources from the EPUB container dynamically, whenever the webview requests them (i.e. byte ranges / binary buffers => Blob URIs). Another example is when loading an exploded EPUB (i.e. not zipped) from an HTTP server, and when some resources are "encrypted" (e.g. obfuscated fonts). In this case, a wholesale replacement of all font references (i.e. URLs) is necessary, and unfortunately this is a "viral" behaviour that impacts all associated resources: fonts faces are declared in CSS, so the stylesheets must be "patched" and consequently served as Blob URIs ... but stylesheets are referenced from HTML files, so they too must be converted to binary blobs. Finally, there is the base case of the top-level HTML file (i.e. the one passed to its host iframe), which needs to be injected "ahead of time" with custom CSS or MathJax (this is from the top of my head, I do not remember exactly). When this is needed, the HTML URL becomes a Blob URI, and the <head><base href="..."> construct is used so that resources linked from the HTML document can simply resolve with their normal URL (i.e. not Blob).