From fdf7fda0d971e4775d054398b8faf29667832f7f Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Mon, 3 Jul 2017 14:16:32 -0400 Subject: [PATCH] Include url-polyfill by default, fix linear default to yes --- karma.conf.js | 2 +- libs/url/{url.js => url-polyfill.js} | 19 +++++++++++++------ package.json | 2 +- src/epub.js | 1 + src/packaging.js | 2 +- webpack.config.js | 2 +- 6 files changed, 18 insertions(+), 10 deletions(-) rename libs/url/{url.js => url-polyfill.js} (97%) diff --git a/karma.conf.js b/karma.conf.js index f424d0e..7bbf744 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -26,7 +26,7 @@ module.exports = function(config) { // {pattern: 'node_modules/es6-promise/dist/es6-promise.auto.js', watched: false, included: true, served: true}, - {pattern: 'libs/url/url.js', watched: false, included: true, served: true} + {pattern: 'libs/url/url-polyfill.js', watched: false, included: true, served: true} ], diff --git a/libs/url/url.js b/libs/url/url-polyfill.js similarity index 97% rename from libs/url/url.js rename to libs/url/url-polyfill.js index 18f16fc..d0137ea 100644 --- a/libs/url/url.js +++ b/libs/url/url-polyfill.js @@ -1,19 +1,26 @@ +/* From https://github.com/webcomponents/URL/blob/master/url.js + * Added UMD, file link handling */ + /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ 'use strict'; (function (root, factory) { - if (typeof define === 'function' && define.amd) { + // Fix for this being undefined in modules + if (!root) { + root = window || global; + } + if (typeof module === 'object' && module.exports) { + // Node + console.log("root", root); + module.exports = factory(root); + } else if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define([], factory); - } else if (typeof module === 'object' && module.exports) { - // Node - module.exports = factory(global); } else { // Browser globals (root is window) root.URL = factory(root); } }(this, function (scope) { - // feature detect for URL constructor var hasWorkingUrl = false; if (!scope.forceJURL) { @@ -595,7 +602,7 @@ // WebKit/Blink returns String("SCHEME://") for file: mailto: switch (this._scheme) { case 'file': - return 'file://' + return 'file://' // EPUBJS Added case 'data': case 'javascript': case 'mailto': diff --git a/package.json b/package.json index a4c8962..c6b6fa1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "epubjs", - "version": "0.3.38", + "version": "0.3.39", "description": "Parse and Render Epubs", "main": "lib/index.js", "module": "src/index.js", diff --git a/src/epub.js b/src/epub.js index d4438c6..18aa623 100644 --- a/src/epub.js +++ b/src/epub.js @@ -3,6 +3,7 @@ import EpubCFI from "./epubcfi"; import Rendition from "./rendition"; import Contents from "./contents"; import * as core from "./utils/core"; +import '../libs/url/url-polyfill' /** * Creates a new Book diff --git a/src/packaging.js b/src/packaging.js index a1c2859..fabc3e0 100644 --- a/src/packaging.js +++ b/src/packaging.js @@ -163,7 +163,7 @@ class Packaging { var itemref = { "idref" : idref, - "linear" : item.getAttribute("linear") || "", + "linear" : item.getAttribute("linear") || "yes", "properties" : propArray, // "href" : manifest[Id].href, // "url" : manifest[Id].url, diff --git a/webpack.config.js b/webpack.config.js index 5f9bd4d..83eac35 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -6,7 +6,7 @@ var LEGACY = (process.env.LEGACY) var hostname = "localhost"; var port = 8080; var enter = LEGACY ? { - "epub.legacy": ["babel-polyfill", "./libs/url/url.js", "./src/epub.js"] + "epub.legacy": ["babel-polyfill", "./src/epub.js"] } : { "epub": "./src/epub.js", };