extracted code from readium-js-viewer into readium-shared-js (now usable by native apps as well)