1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-05 15:32:55 +02:00
epub.js/dist/polyfills.min.js
2016-11-15 15:21:56 +01:00

10 lines
No EOL
17 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ePub=e():t.ePub=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var r=i[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var i={};return e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,e,i){Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var i=t&&t.__esModule?function(){return t["default"]}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=51)}({14:function(t,e){/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
!function(e){"use strict";function i(t){return void 0!==_[t]}function n(){c.call(this),this._isInvalid=!0}function r(t){return""==t&&n.call(this),t.toLowerCase()}function s(t){var e=t.charCodeAt(0);return e>32&&e<127&&[34,35,60,62,63,96].indexOf(e)==-1?t:encodeURIComponent(t)}function o(t){var e=t.charCodeAt(0);return e>32&&e<127&&[34,35,60,62,96].indexOf(e)==-1?t:encodeURIComponent(t)}function a(t,e,a){function c(t){y.push(t)}var h=e||"scheme start",u=0,l="",f=!1,b=!1,y=[];t:for(;(t[u-1]!=v||0==u)&&!this._isInvalid;){var g=t[u];switch(h){case"scheme start":if(!g||!d.test(g)){if(e){c("Invalid scheme.");break t}l="",h="no scheme";continue}l+=g.toLowerCase(),h="scheme";break;case"scheme":if(g&&m.test(g))l+=g.toLowerCase();else{if(":"!=g){if(e){if(v==g)break t;c("Code point not allowed in scheme: "+g);break t}l="",u=0,h="no scheme";continue}if(this._scheme=l,l="",e)break t;i(this._scheme)&&(this._isRelative=!0),h="file"==this._scheme?"relative":this._isRelative&&a&&a._scheme==this._scheme?"relative or authority":this._isRelative?"authority first slash":"scheme data"}break;case"scheme data":"?"==g?(this._query="?",h="query"):"#"==g?(this._fragment="#",h="fragment"):v!=g&&"\t"!=g&&"\n"!=g&&"\r"!=g&&(this._schemeData+=s(g));break;case"no scheme":if(a&&i(a._scheme)){h="relative";continue}c("Missing scheme."),n.call(this);break;case"relative or authority":if("/"!=g||"/"!=t[u+1]){c("Expected /, got: "+g),h="relative";continue}h="authority ignore slashes";break;case"relative":if(this._isRelative=!0,"file"!=this._scheme&&(this._scheme=a._scheme),v==g){this._host=a._host,this._port=a._port,this._path=a._path.slice(),this._query=a._query,this._username=a._username,this._password=a._password;break t}if("/"==g||"\\"==g)"\\"==g&&c("\\ is an invalid code point."),h="relative slash";else if("?"==g)this._host=a._host,this._port=a._port,this._path=a._path.slice(),this._query="?",this._username=a._username,this._password=a._password,h="query";else{if("#"!=g){var w=t[u+1],j=t[u+2];("file"!=this._scheme||!d.test(g)||":"!=w&&"|"!=w||v!=j&&"/"!=j&&"\\"!=j&&"?"!=j&&"#"!=j)&&(this._host=a._host,this._port=a._port,this._username=a._username,this._password=a._password,this._path=a._path.slice(),this._path.pop()),h="relative path";continue}this._host=a._host,this._port=a._port,this._path=a._path.slice(),this._query=a._query,this._fragment="#",this._username=a._username,this._password=a._password,h="fragment"}break;case"relative slash":if("/"!=g&&"\\"!=g){"file"!=this._scheme&&(this._host=a._host,this._port=a._port,this._username=a._username,this._password=a._password),h="relative path";continue}"\\"==g&&c("\\ is an invalid code point."),h="file"==this._scheme?"file host":"authority ignore slashes";break;case"authority first slash":if("/"!=g){c("Expected '/', got: "+g),h="authority ignore slashes";continue}h="authority second slash";break;case"authority second slash":if(h="authority ignore slashes","/"!=g){c("Expected '/', got: "+g);continue}break;case"authority ignore slashes":if("/"!=g&&"\\"!=g){h="authority";continue}c("Expected authority, got: "+g);break;case"authority":if("@"==g){f&&(c("@ already seen."),l+="%40"),f=!0;for(var O=0;O<l.length;O++){var k=l[O];if("\t"!=k&&"\n"!=k&&"\r"!=k)if(":"!=k||null!==this._password){var A=s(k);null!==this._password?this._password+=A:this._username+=A}else this._password="";else c("Invalid whitespace in authority.")}l=""}else{if(v==g||"/"==g||"\\"==g||"?"==g||"#"==g){u-=l.length,l="",h="host";continue}l+=g}break;case"file host":if(v==g||"/"==g||"\\"==g||"?"==g||"#"==g){2!=l.length||!d.test(l[0])||":"!=l[1]&&"|"!=l[1]?0==l.length?h="relative path start":(this._host=r.call(this,l),l="",h="relative path start"):h="relative path";continue}"\t"==g||"\n"==g||"\r"==g?c("Invalid whitespace in file host."):l+=g;break;case"host":case"hostname":if(":"!=g||b){if(v==g||"/"==g||"\\"==g||"?"==g||"#"==g){if(this._host=r.call(this,l),l="",h="relative path start",e)break t;continue}"\t"!=g&&"\n"!=g&&"\r"!=g?("["==g?b=!0:"]"==g&&(b=!1),l+=g):c("Invalid code point in host/hostname: "+g)}else if(this._host=r.call(this,l),l="",h="port","hostname"==e)break t;break;case"port":if(/[0-9]/.test(g))l+=g;else{if(v==g||"/"==g||"\\"==g||"?"==g||"#"==g||e){if(""!=l){var x=parseInt(l,10);x!=_[this._scheme]&&(this._port=x+""),l=""}if(e)break t;h="relative path start";continue}"\t"==g||"\n"==g||"\r"==g?c("Invalid code point in port: "+g):n.call(this)}break;case"relative path start":if("\\"==g&&c("'\\' not allowed in path."),h="relative path","/"!=g&&"\\"!=g)continue;break;case"relative path":if(v!=g&&"/"!=g&&"\\"!=g&&(e||"?"!=g&&"#"!=g))"\t"!=g&&"\n"!=g&&"\r"!=g&&(l+=s(g));else{"\\"==g&&c("\\ not allowed in relative path.");var T;(T=p[l.toLowerCase()])&&(l=T),".."==l?(this._path.pop(),"/"!=g&&"\\"!=g&&this._path.push("")):"."==l&&"/"!=g&&"\\"!=g?this._path.push(""):"."!=l&&("file"==this._scheme&&0==this._path.length&&2==l.length&&d.test(l[0])&&"|"==l[1]&&(l=l[0]+":"),this._path.push(l)),l="","?"==g?(this._query="?",h="query"):"#"==g&&(this._fragment="#",h="fragment")}break;case"query":e||"#"!=g?v!=g&&"\t"!=g&&"\n"!=g&&"\r"!=g&&(this._query+=o(g)):(this._fragment="#",h="fragment");break;case"fragment":v!=g&&"\t"!=g&&"\n"!=g&&"\r"!=g&&(this._fragment+=g)}u++}}function c(){this._scheme="",this._schemeData="",this._username="",this._password=null,this._host="",this._port="",this._path=[],this._query="",this._fragment="",this._isInvalid=!1,this._isRelative=!1}function h(t,e){void 0===e||e instanceof h||(e=new h(String(e))),this._url=t,c.call(this);var i=t.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g,"");a.call(this,i,null,e)}var u=!1;if(!e.forceJURL)try{var l=new URL("b","http://a");l.pathname="c%20d",u="http://a/c%20d"===l.href}catch(f){}if(!u){var _=Object.create(null);_.ftp=21,_.file=0,_.gopher=70,_.http=80,_.https=443,_.ws=80,_.wss=443;var p=Object.create(null);p["%2e"]=".",p[".%2e"]="..",p["%2e."]="..",p["%2e%2e"]="..";var v=void 0,d=/[a-zA-Z]/,m=/[a-zA-Z0-9\+\-\.]/;h.prototype={toString:function(){return this.href},get href(){if(this._isInvalid)return this._url;var t="";return""==this._username&&null==this._password||(t=this._username+(null!=this._password?":"+this._password:"")+"@"),this.protocol+(this._isRelative?"//"+t+this.host:"")+this.pathname+this._query+this._fragment},set href(t){c.call(this),a.call(this,t)},get protocol(){return this._scheme+":"},set protocol(t){this._isInvalid||a.call(this,t+":","scheme start")},get host(){return this._isInvalid?"":this._port?this._host+":"+this._port:this._host},set host(t){!this._isInvalid&&this._isRelative&&a.call(this,t,"host")},get hostname(){return this._host},set hostname(t){!this._isInvalid&&this._isRelative&&a.call(this,t,"hostname")},get port(){return this._port},set port(t){!this._isInvalid&&this._isRelative&&a.call(this,t,"port")},get pathname(){return this._isInvalid?"":this._isRelative?"/"+this._path.join("/"):this._schemeData},set pathname(t){!this._isInvalid&&this._isRelative&&(this._path=[],a.call(this,t,"relative path start"))},get search(){return this._isInvalid||!this._query||"?"==this._query?"":this._query},set search(t){!this._isInvalid&&this._isRelative&&(this._query="?","?"==t[0]&&(t=t.slice(1)),a.call(this,t,"query"))},get hash(){return this._isInvalid||!this._fragment||"#"==this._fragment?"":this._fragment},set hash(t){this._isInvalid||(this._fragment="#","#"==t[0]&&(t=t.slice(1)),a.call(this,t,"fragment"))},get origin(){var t;if(this._isInvalid||!this._scheme)return"";switch(this._scheme){case"data":case"file":case"javascript":case"mailto":return"null"}return t=this.host,t?this._scheme+"://"+t:""}};var b=e.URL;b&&(h.createObjectURL=function(t){return b.createObjectURL.apply(b,arguments)},h.revokeObjectURL=function(t){b.revokeObjectURL(t)}),e.URL=h,"object"==typeof t&&t.exports&&(t.exports=h)}}(this)},15:function(t,e,i){(function(e,n){/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version 4.0.5
*/
!function(e,i){t.exports=i()}(this,function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function r(t){return"function"==typeof t}function s(t){G=t}function o(t){H=t}function a(){return function(){return e.nextTick(f)}}function c(){return"undefined"!=typeof B?function(){B(f)}:l()}function h(){var t=0,e=new X(f),i=document.createTextNode("");return e.observe(i,{characterData:!0}),function(){i.data=t=++t%2}}function u(){var t=new MessageChannel;return t.port1.onmessage=f,function(){return t.port2.postMessage(0)}}function l(){var t=setTimeout;return function(){return t(f,1)}}function f(){for(var t=0;t<$;t+=2){var e=it[t],i=it[t+1];e(i),it[t]=void 0,it[t+1]=void 0}$=0}function _(){try{var t=i(49);return B=t.runOnLoop||t.runOnContext,c()}catch(e){return l()}}function p(t,e){var i=arguments,n=this,r=new this.constructor(d);void 0===r[rt]&&P(r);var s=n._state;return s?!function(){var t=i[s-1];H(function(){return L(s,r,t,n._result)})}():I(n,r,t,e),r}function v(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var i=new e(d);return k(i,t),i}function d(){}function m(){return new TypeError("You cannot resolve a promise with itself")}function b(){return new TypeError("A promises callback cannot return that same promise.")}function y(t){try{return t.then}catch(e){return ct.error=e,ct}}function g(t,e,i,n){try{t.call(e,i,n)}catch(r){return r}}function w(t,e,i){H(function(t){var n=!1,r=g(i,e,function(i){n||(n=!0,e!==i?k(t,i):x(t,i))},function(e){n||(n=!0,T(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&r&&(n=!0,T(t,r))},t)}function j(t,e){e._state===ot?x(t,e._result):e._state===at?T(t,e._result):I(e,void 0,function(e){return k(t,e)},function(e){return T(t,e)})}function O(t,e,i){e.constructor===t.constructor&&i===p&&e.constructor.resolve===v?j(t,e):i===ct?T(t,ct.error):void 0===i?x(t,e):r(i)?w(t,e,i):x(t,e)}function k(e,i){e===i?T(e,m()):t(i)?O(e,i,y(i)):x(e,i)}function A(t){t._onerror&&t._onerror(t._result),R(t)}function x(t,e){t._state===st&&(t._result=e,t._state=ot,0!==t._subscribers.length&&H(R,t))}function T(t,e){t._state===st&&(t._state=at,t._result=e,H(A,t))}function I(t,e,i,n){var r=t._subscribers,s=r.length;t._onerror=null,r[s]=e,r[s+ot]=i,r[s+at]=n,0===s&&t._state&&H(R,t)}function R(t){var e=t._subscribers,i=t._state;if(0!==e.length){for(var n=void 0,r=void 0,s=t._result,o=0;o<e.length;o+=3)n=e[o],r=e[o+i],n?L(i,n,r,s):r(s);t._subscribers.length=0}}function q(){this.error=null}function E(t,e){try{return t(e)}catch(i){return ht.error=i,ht}}function L(t,e,i,n){var s=r(i),o=void 0,a=void 0,c=void 0,h=void 0;if(s){if(o=E(i,n),o===ht?(h=!0,a=o.error,o=null):c=!0,e===o)return void T(e,b())}else o=n,c=!0;e._state!==st||(s&&c?k(e,o):h?T(e,a):t===ot?x(e,o):t===at&&T(e,o))}function C(t,e){try{e(function(e){k(t,e)},function(e){T(t,e)})}catch(i){T(t,i)}}function S(){return ut++}function P(t){t[rt]=ut++,t._state=void 0,t._result=void 0,t._subscribers=[]}function U(t,e){this._instanceConstructor=t,this.promise=new t(d),this.promise[rt]||P(this.promise),W(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?x(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&x(this.promise,this._result))):T(this.promise,M())}function M(){return new Error("Array Methods must be provided an Array")}function D(t){return new U(this,t).promise}function F(t){var e=this;return new e(W(t)?function(i,n){for(var r=t.length,s=0;s<r;s++)e.resolve(t[s]).then(i,n)}:function(t,e){return e(new TypeError("You must pass an array to race."))})}function Y(t){var e=this,i=new e(d);return T(i,t),i}function z(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function Z(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function J(t){this[rt]=S(),this._result=this._state=void 0,this._subscribers=[],d!==t&&("function"!=typeof t&&z(),this instanceof J?C(this,t):Z())}function K(){var t=void 0;if("undefined"!=typeof n)t=n;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var i=t.Promise;if(i){var r=null;try{r=Object.prototype.toString.call(i.resolve())}catch(e){}if("[object Promise]"===r&&!i.cast)return}t.Promise=J}var N=void 0;N=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var W=N,$=0,B=void 0,G=void 0,H=function(t,e){it[$]=t,it[$+1]=e,$+=2,2===$&&(G?G(f):nt())},Q="undefined"!=typeof window?window:void 0,V=Q||{},X=V.MutationObserver||V.WebKitMutationObserver,tt="undefined"==typeof self&&"undefined"!=typeof e&&"[object process]"==={}.toString.call(e),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,it=new Array(1e3),nt=void 0;nt=tt?a():X?h():et?u():void 0===Q?_():l();var rt=Math.random().toString(36).substring(16),st=void 0,ot=1,at=2,ct=new q,ht=new q,ut=0;return U.prototype._enumerate=function(){for(var t=this.length,e=this._input,i=0;this._state===st&&i<t;i++)this._eachEntry(e[i],i)},U.prototype._eachEntry=function(t,e){var i=this._instanceConstructor,n=i.resolve;if(n===v){var r=y(t);if(r===p&&t._state!==st)this._settledAt(t._state,e,t._result);else if("function"!=typeof r)this._remaining--,this._result[e]=t;else if(i===J){var s=new i(d);O(s,t,r),this._willSettleAt(s,e)}else this._willSettleAt(new i(function(e){return e(t)}),e)}else this._willSettleAt(n(t),e)},U.prototype._settledAt=function(t,e,i){var n=this.promise;n._state===st&&(this._remaining--,t===at?T(n,i):this._result[e]=i),0===this._remaining&&x(n,this._result)},U.prototype._willSettleAt=function(t,e){var i=this;I(t,void 0,function(t){return i._settledAt(ot,e,t)},function(t){return i._settledAt(at,e,t)})},J.all=D,J.race=F,J.resolve=v,J.reject=Y,J._setScheduler=s,J._setAsap=o,J._asap=H,J.prototype={constructor:J,then:p,"catch":function(t){return this.then(null,t)}},J.polyfill=K,J.Promise=J,J}),ES6Promise.polyfill()}).call(e,i(4),i(35))},35:function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(n){"object"==typeof window&&(i=window)}t.exports=i},4:function(t,e){function i(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function r(t){if(u===setTimeout)return setTimeout(t,0);if((u===i||!u)&&setTimeout)return u=setTimeout,setTimeout(t,0);try{return u(t,0)}catch(e){try{return u.call(null,t,0)}catch(e){return u.call(this,t,0)}}}function s(t){if(l===clearTimeout)return clearTimeout(t);if((l===n||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function o(){v&&_&&(v=!1,_.length?p=_.concat(p):d=-1,p.length&&a())}function a(){if(!v){var t=r(o);v=!0;for(var e=p.length;e;){for(_=p,p=[];++d<e;)_&&_[d].run();d=-1,e=p.length}_=null,v=!1,s(t)}}function c(t,e){this.fun=t,this.array=e}function h(){}var u,l,f=t.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:i}catch(t){u=i}try{l="function"==typeof clearTimeout?clearTimeout:n}catch(t){l=n}}();var _,p=[],v=!1,d=-1;f.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];p.push(new c(t,e)),1!==p.length||v||r(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},f.title="browser",f.browser=!0,f.env={},f.argv=[],f.version="",f.versions={},f.on=h,f.addListener=h,f.once=h,f.off=h,f.removeListener=h,f.removeAllListeners=h,f.emit=h,f.binding=function(t){throw new Error("process.binding is not supported")},f.cwd=function(){return"/"},f.chdir=function(t){throw new Error("process.chdir is not supported")},f.umask=function(){return 0}},49:function(t,e){},51:function(t,e,i){i(15),t.exports=i(14)}})});