New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cordova-app-loader

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-app-loader - npm Package Compare versions

Comparing version 0.14.0 to 0.15.0

2

bootstrap.js

@@ -93,3 +93,3 @@ (function(){

// If we're loading Cordova files, make sure Cordova is ready first!
if(manifest.root.substr(0,7) === 'cdvfile'){
if(typeof window.cordova !== 'undefined'){
document.addEventListener("deviceready", loadScripts, false);

@@ -96,0 +96,0 @@ } else {

{
"name": "cordova-app-loadaer",
"main": "dist/CordovaAppLoader.js",
"version": "0.14.0",
"version": "0.15.0",
"homepage": "https://github.com/markmarijnissen/cordova-file-cache",

@@ -6,0 +6,0 @@ "authors": [

@@ -93,3 +93,3 @@ (function(){

// If we're loading Cordova files, make sure Cordova is ready first!
if(manifest.root.substr(0,7) === 'cdvfile'){
if(typeof window.cordova !== 'undefined'){
document.addEventListener("deviceready", loadScripts, false);

@@ -96,0 +96,0 @@ } else {

@@ -1,1 +0,1 @@

!function(){function t(t,e,o){function n(){r.forEach(function(e){e&&("/"===e[0]&&(e=e.substr(1)),e=t.root+e,".js"===e.substr(-3)?(s=document.createElement("script"),s.type="text/javascript",s.src=e+"?"+i,s.async=!1):(s=document.createElement("link"),s.rel="stylesheet",s.href=e+"?"+i,s.type="text/css"),a.appendChild(s))})}if(!t.load)return void console.error("Manifest has nothing to load (manifest.load is empty).",t);var s,a=document.getElementsByTagName("head")[0],r=t.load.concat(),i=Date.now();t.root=t.root||"./",t.root.length>0&&"/"!==t.root[t.root.length-1]&&(t.root+="/"),e||localStorage.setItem("manifest",JSON.stringify(t)),"cdvfile"===t.root.substr(0,7)?document.addEventListener("deviceready",n,!1):n(),window.Manifest=t,e&&setTimeout(function(){window.BOOTSTRAP_OK||(console.warn("BOOTSTRAP_OK !== true; Resetting to original manifest.json..."),localStorage.removeItem("manifest"),location.reload())},o)}window.pegasus=function(t,e){return e=new XMLHttpRequest,e.open("GET",t),t=[],e.onreadystatechange=e.then=function(o,n,s){o.call&&(t=[o,n]),4==e.readyState&&(s=t[0|e.status/400],s&&s(200===e.status||0===e.status?JSON.parse(e.responseText):e))},e.send(),e},window.Manifest={};var e=JSON.parse(localStorage.getItem("manifest")),o=document.querySelector("script[manifest]");if(e)t(e,!0,o.getAttribute("timeout")||1e4);else{var n=(o?o.getAttribute("manifest"):null)||"manifest.json";pegasus(n).then(t,function(t){console.error("Could not download "+n+": "+t.status)})}}();
!function(){function t(t,e,o){function n(){r.forEach(function(e){e&&("/"===e[0]&&(e=e.substr(1)),e=t.root+e,".js"===e.substr(-3)?(a=document.createElement("script"),a.type="text/javascript",a.src=e+"?"+i,a.async=!1):(a=document.createElement("link"),a.rel="stylesheet",a.href=e+"?"+i,a.type="text/css"),s.appendChild(a))})}if(!t.load)return void console.error("Manifest has nothing to load (manifest.load is empty).",t);var a,s=document.getElementsByTagName("head")[0],r=t.load.concat(),i=Date.now();t.root=t.root||"./",t.root.length>0&&"/"!==t.root[t.root.length-1]&&(t.root+="/"),e||localStorage.setItem("manifest",JSON.stringify(t)),"undefined"!=typeof window.cordova?document.addEventListener("deviceready",n,!1):n(),window.Manifest=t,e&&setTimeout(function(){window.BOOTSTRAP_OK||(console.warn("BOOTSTRAP_OK !== true; Resetting to original manifest.json..."),localStorage.removeItem("manifest"),location.reload())},o)}window.pegasus=function(t,e){return e=new XMLHttpRequest,e.open("GET",t),t=[],e.onreadystatechange=e.then=function(o,n,a){o.call&&(t=[o,n]),4==e.readyState&&(a=t[0|e.status/400],a&&a(200===e.status||0===e.status?JSON.parse(e.responseText):e))},e.send(),e},window.Manifest={};var e=JSON.parse(localStorage.getItem("manifest")),o=document.querySelector("script[manifest]");if(e)t(e,!0,o.getAttribute("timeout")||1e4);else{var n=(o?o.getAttribute("manifest"):null)||"manifest.json";pegasus(n).then(t,function(t){console.error("Could not download "+n+": "+t.status)})}}();
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -18,23 +18,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports

@@ -234,2 +234,4 @@ /******/ return __webpack_require__(0);

}
}, function(err){
reject(err);
}); // end of .then

@@ -250,3 +252,3 @@ }); // end of new Promise

if(!self.canDownload()) {
return Promise.resolve(null);
return new Promise(function(resolve){ resolve(null); });
}

@@ -554,2 +556,6 @@ // we will delete files, which will invalidate the current manifest...

if(this._mirrorMode) {
var query = url.indexOf('?');
if(query > -1){
url = url.substr(0,query);
}
url = url = this._fs.normalize(url || '');

@@ -616,3 +622,3 @@ len = this.serverRoot.length;

var Promise = options.Promise || window.Promise;
if(!Promise) { throw new Error("No Promise library given in options.Promise"); }
if(typeof Promise === 'undefined') { throw new Error("No Promise library given in options.Promise"); }

@@ -703,3 +709,3 @@ /* default options */

folders = folders.split('/').filter(function(folder) {
return folder && folder.length > 0 && folder[0] !== '.';
return folder && folder.length > 0 && folder !== '.' && folder !== '..';
});

@@ -815,3 +821,3 @@ __createDir(fs.root,folders,resolve,reject);

path = normalize(path);
return 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path;
return path.indexOf('://') < 0? 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path: path;
};

@@ -976,4 +982,3 @@

}
serverUrl = encodeURI(serverUrl);
if(isCordova) localPath = toInternalURLSync(localPath);
if(isCordova && localPath.indexOf('://') < 0) localPath = toInternalURLSync(localPath);

@@ -985,2 +990,5 @@ transferOptions = transferOptions || {};

transferOptions.retry = transferOptions.retry.concat();
if(!transferOptions.file && !isDownload){
transferOptions.fileName = filename(localPath);
}

@@ -1060,2 +1068,3 @@ var ft = new FileTransfer();

/***/ },

@@ -1065,3 +1074,3 @@ /* 4 */

/**@license MIT-promiscuous-©Ruben Verborgh*/
/* WEBPACK VAR INJECTION */(function(setImmediate) {/**@license MIT-promiscuous-©Ruben Verborgh*/
(function (func, obj) {

@@ -1194,2 +1203,3 @@ // Type checking utility function

/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6).setImmediate))

@@ -1267,3 +1277,149 @@ /***/ },

/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(7).nextTick;
var apply = Function.prototype.apply;
var slice = Array.prototype.slice;
var immediateIds = {};
var nextImmediateId = 0;
// DOM APIs, for completeness
exports.setTimeout = function() {
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
};
exports.setInterval = function() {
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
};
exports.clearTimeout =
exports.clearInterval = function(timeout) { timeout.close(); };
function Timeout(id, clearFn) {
this._id = id;
this._clearFn = clearFn;
}
Timeout.prototype.unref = Timeout.prototype.ref = function() {};
Timeout.prototype.close = function() {
this._clearFn.call(window, this._id);
};
// Does not start the time, just sets up the members needed.
exports.enroll = function(item, msecs) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = msecs;
};
exports.unenroll = function(item) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = -1;
};
exports._unrefActive = exports.active = function(item) {
clearTimeout(item._idleTimeoutId);
var msecs = item._idleTimeout;
if (msecs >= 0) {
item._idleTimeoutId = setTimeout(function onTimeout() {
if (item._onTimeout)
item._onTimeout();
}, msecs);
}
};
// That's not how node.js implements it but the exposed api is the same.
exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
var id = nextImmediateId++;
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
immediateIds[id] = true;
nextTick(function onNextTick() {
if (immediateIds[id]) {
// fn.call() is faster so we optimize for the common use-case
// @see http://jsperf.com/call-apply-segu
if (args) {
fn.apply(null, args);
} else {
fn.call(null);
}
// Prevent ids from leaking
exports.clearImmediate(id);
}
});
return id;
};
exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
delete immediateIds[id];
};
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6).setImmediate, __webpack_require__(6).clearImmediate))
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
// shim for using process in browser
var process = module.exports = {};
var queue = [];
var draining = false;
function drainQueue() {
if (draining) {
return;
}
draining = true;
var currentQueue;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
var i = -1;
while (++i < len) {
currentQueue[i]();
}
len = queue.length;
}
draining = false;
}
process.nextTick = function (fun) {
queue.push(fun);
if (!draining) {
setTimeout(drainQueue, 0);
}
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
// TODO(shtylman)
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }
/******/ ])
/******/ ]);

@@ -1,1 +0,1 @@

!function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){window.CordovaAppLoader=n(1),window.CordovaFileCache=n(2),window.CordovaPromiseFS=n(3),window.Promise=n(4),window.setImmediate=window.setTimeout},function(t,e,n){function o(t){if(!t)throw new Error("CordovaAppLoader has no options!");if(!t.fs)throw new Error('CordovaAppLoader has no "fs" option (cordova-promise-fs)');if(!t.serverRoot)throw new Error('CordovaAppLoader has no "serverRoot" option.');if(!window.pegasus||!window.Manifest)throw new Error("CordovaAppLoader bootstrap.js is missing.");this.allowServerRootFromManifest=t.allowServerRootFromManifest===!0,i=t.fs.Promise,this.manifest=window.Manifest,this.newManifest=null,this.bundledManifest=null,this._lastUpdateFiles=localStorage.getItem("last_update_files"),t.serverRoot=t.serverRoot||"",t.serverRoot&&"/"!==t.serverRoot[t.serverRoot.length-1]&&(t.serverRoot+="/"),this.newManifestUrl=t.manifestUrl||t.serverRoot+(t.manifest||"manifest.json"),t.mode&&(t.mode="mirror"),this.cache=new r(t),this.corruptNewManifest=!1,this._toBeCopied=[],this._toBeDeleted=[],this._toBeDownloaded=[],this._updateReady=!1,this._checkTimeout=t.checkTimeout||1e4}var r=n(2),i=(n(3),null),a=location.href.replace(location.hash,"");a=a.substr(0,a.lastIndexOf("/")+1),/ip(hone|ad|od)/i.test(navigator.userAgent)&&(a=location.pathname.substr(location.pathname.indexOf("/www/")),a=a.substr(0,a.lastIndexOf("/")+1),a="cdvfile://localhost/bundle"+a),o.prototype._createFilemap=function(t){var e={},n=this.cache._fs.normalize;return Object.keys(t).forEach(function(o){t[o].filename=n(t[o].filename),e[t[o].filename]=t[o]}),e},o.prototype.copyFromBundle=function(t){var e=a+t;return this.cache._fs.download(e,this.cache.localRoot+t)},o.prototype.getBundledManifest=function(){var t=this,e=document.querySelector("script[manifest]"),n=(e?e.getAttribute("manifest"):null)||"manifest.json";return new i(function(e,o){t.bundledManifest?e(t.bundledManifest):(pegasus(n).then(function(n){t.bundledManifest=n,e(n)},o),setTimeout(function(){o(new Error("bundled manifest timeout"))},t._checkTimeout))})},o.prototype.check=function(t){var e=this,n=this.manifest;"string"==typeof t&&(e.newManifestUrl=t,t=void 0);var o=new i(function(n,o){"object"==typeof t?n(t):(pegasus(e.newManifestUrl).then(n,o),setTimeout(function(){o(new Error("new manifest timeout"))},e._checkTimeout))});return new i(function(t,r){i.all([o,e.getBundledManifest(),e.cache.list()]).then(function(o){var i=o[0],a=o[1];if(JSON.stringify(i.files)===e._lastUpdateFiles)return JSON.stringify(i.files)!==JSON.stringify(Manifest.files)&&(console.warn("New manifest available, but an earlier update attempt failed. Will not download."),e.corruptNewManifest=!0,t(null)),void t(!1);if(!i.files)return void r('Downloaded Manifest has no "files" attribute.');var s=o[2],u=e._createFilemap(n.files),c=e._createFilemap(i.files),f=e._createFilemap(a.files);e._toBeDownloaded=[],e._toBeCopied=[],e._toBeDeleted=[];var l=e.cache._fs.isCordova;Object.keys(c).filter(function(t){return!u[t]||u[t].version!==c[t].version||!e.cache.isCached(t)}).forEach(function(t){l&&f[t]&&f[t].version===c[t].version?e._toBeCopied.push(t):e._toBeDownloaded.push(t)}),e._toBeDeleted=s.map(function(t){return t.substr(e.cache.localRoot.length)}).filter(function(t){return!c[t]||e._toBeDownloaded.indexOf(t)>=0||e._toBeCopied.indexOf(t)>=0});var d=e._toBeDeleted.length+e._toBeDownloaded.length;d>0?(e.newManifest=i,e.newManifest.root=e.cache.localInternalURL,t(!0)):t(!1)})})},o.prototype.canDownload=function(){return!!this.newManifest&&!this._updateReady},o.prototype.canUpdate=function(){return this._updateReady},o.prototype.download=function(t){var e=this;return e.canDownload()?(localStorage.removeItem("manifest"),localStorage.setItem("last_update_files",JSON.stringify(this.newManifest.files)),this.manifest.files=Manifest.files={},e.cache.remove(e._toBeDeleted,!0).then(function(){return i.all(e._toBeCopied.map(function(t){return e.cache._fs.download(a+t,e.cache.localRoot+t)}))}).then(function(){return e.allowServerRootFromManifest&&e.newManifest.serverRoot&&(e.cache.serverRoot=e.newManifest.serverRoot),e.cache.add(e._toBeDownloaded),e.cache.download(t)}).then(function(){return e._toBeDeleted=[],e._toBeDownloaded=[],e._updateReady=!0,e.newManifest},function(t){return t&&t.length&&e.cache.remove(t),t})):i.resolve(null)},o.prototype.update=function(t){return this._updateReady?(localStorage.setItem("manifest",JSON.stringify(this.newManifest)),t!==!1&&location.reload(),!0):!1},o.prototype.clear=function(){return localStorage.removeItem("last_update_files"),localStorage.removeItem("manifest"),this.cache.clear()},o.prototype.reset=function(){return this.clear().then(function(){location.reload()},function(){location.reload()})},t.exports=o},function(t,e,n){function o(t){var e=this;if(this._fs=t.fs,!this._fs)throw new Error('Missing required option "fs". Add an instance of cordova-promise-fs.');i=this._fs.Promise,this._mirrorMode="hash"!==t.mode,this._retry=t.retry||[500,1500,8e3],this._cacheBuster=!!t.cacheBuster,this.localRoot=this._fs.normalize(t.localRoot||"data"),this.serverRoot=this._fs.normalize(t.serverRoot||""),this._downloading=[],this._added=[],this._cached={},this.ready=this._fs.ensure(this.localRoot).then(function(t){return e.localInternalURL=a?t.toInternalURL():t.toURL(),e.localUrl=t.toURL(),e.list()})}var r=n(5),i=null,a="undefined"!=typeof cordova;o.prototype.list=function(){var t=this;return new i(function(e){t._fs.list(t.localRoot,"rfe").then(function(n){t._cached={},n=n.map(function(e){var n=t._fs.normalize(e.fullPath);return t._cached[n]={toInternalURL:a?e.toInternalURL():e.toURL(),toURL:e.toURL()},n}),e(n)},function(){e([])})})},o.prototype.add=function(t){t||(t=[]),"string"==typeof t&&(t=[t]);var e=this;return t.forEach(function(t){t=e.toServerURL(t),-1===e._added.indexOf(t)&&e._added.push(t)}),e.isDirty()},o.prototype.remove=function(t,e){t||(t=[]);var n=[];"string"==typeof t&&(t=[t]);var o=this;return t.forEach(function(t){var e=o._added.indexOf(o.toServerURL(t));e>=0&&o._added.splice(e,1);var r=o.toPath(t);n.push(o._fs.remove(r)),delete o._cached[r]}),e?i.all(n):o.isDirty()},o.prototype.getDownloadQueue=function(){var t=this,e=t._added.filter(function(e){return!t.isCached(e)});return e},o.prototype.getAdded=function(){return this._added},o.prototype.isDirty=function(){return this.getDownloadQueue().length>0},o.prototype.download=function(t){var e=this._fs,n=this;return n.abort(),new i(function(o,r){e.ensure(n.localRoot).then(function(){return n.list()}).then(function(){if(!n.isDirty())return void o(n);var i=n.getDownloadQueue(),a=[],s=n._downloading.length,u=n._downloading.length,c=n._downloading.length+i.length;i.forEach(function(i){var f,l=n.toPath(i);"function"==typeof t&&(f=function(e){e.queueIndex=s,e.queueSize=c,e.url=i,e.path=l,e.percentage=s/c,e.loaded>0&&e.total>0&&s!==c&&(e.percentage+=e.loaded/e.total/c),a.indexOf(i)<0&&(a.push(i),s++),t(e)});var d=function(){u++,u===c&&(n._downloading=[],n.list().then(function(){f&&f(new ProgressEvent),n.isDirty()?r(n.getDownloadQueue()):o(n)},r))},h=i;n._cacheBuster&&(h+="?"+Date.now());var p=e.download(h,l,{retry:n._retry},f);p.then(d,d),n._downloading.push(p)})},r)})},o.prototype.abort=function(){this._downloading.forEach(function(t){t.abort()}),this._downloading=[]},o.prototype.isCached=function(t){return t=this.toPath(t),!!this._cached[t]},o.prototype.clear=function(){var t=this;return this._cached={},this._fs.removeDir(this.localRoot).then(function(){return t._fs.ensure(t.localRoot)})},o.prototype.toInternalURL=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toInternalURL:t},o.prototype.get=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toInternalURL:this.toServerURL(t)},o.prototype.toDataURL=function(t){return this._fs.toDataURL(this.toPath(t))},o.prototype.toURL=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toURL:t},o.prototype.toServerURL=function(t){return t=this._fs.normalize(t),t.indexOf("://")<0?this.serverRoot+t:t},o.prototype.toPath=function(t){return this._mirrorMode?(t=t=this._fs.normalize(t||""),len=this.serverRoot.length,t.substr(0,len)!==this.serverRoot?this.localRoot+t:this.localRoot+t.substr(len)):this.localRoot+r(t)+t.substr(t.lastIndexOf("."))},t.exports=o},function(t){function e(t,n,o,r){t.getDirectory(n[0],{create:!0},function(t){n.length>1?e(t,n.slice(1),o,r):o(t)},r)}function n(t){return t=t.substr(0,t.lastIndexOf("/")+1),"/"===t[0]&&(t=t.substr(1)),t}function o(t){return t.substr(t.lastIndexOf("/")+1)}function r(t){return t=t||"","/"===t[0]&&(t=t.substr(1)),t&&t.indexOf(".")<0&&"/"!==t[t.length-1]&&(t+="/"),"./"===t&&(t=""),t}var i=[],a=0;t.exports=function(t){function s(t){return new x(function(e){return e(t)})}function u(t){return new x(function(n,o){return B.then(function(r){t?(t=t.split("/").filter(function(t){return t&&t.length>0&&"."!==t[0]}),e(r.root,t,n,o)):n(r.root)},o)})}function c(t,e){return new x(function(n,o){return"object"==typeof t?n(t):(t=r(t),e=e||{},B.then(function(r){r.root.getFile(t,e,n,o)},o))})}function f(t,e){return t=r(t),e=e||{},new x(function(n,o){return B.then(function(r){t&&"/"!==t?r.root.getDirectory(t,e,n,o):n(r.root)},o)})}function l(t,e){e=e||"";var n=e.indexOf("r")>-1,o=e.indexOf("e")>-1,r=e.indexOf("f")>-1,i=e.indexOf("d")>-1;return r&&i&&(r=!1,i=!1),new x(function(e,a){return f(t).then(function(t){var u=t.createReader();u.readEntries(function(t){var u=[s(t)];n&&t.filter(function(t){return t.isDirectory}).forEach(function(t){u.push(l(t.fullPath,"re"))}),x.all(u).then(function(t){var n=[];n=n.concat.apply(n,t),r&&(n=n.filter(function(t){return t.isFile})),i&&(n=n.filter(function(t){return t.isDirectory})),o||(n=n.map(function(t){return t.fullPath})),e(n)},a)},a)},a)})}function d(t){return new x(function(e,n){c(t).then(function(t){e(t)},function(t){1===t.code?e(!1):n(t)})})}function h(t){return u(n(t)).then(function(){return c(t,{create:!0})})}function p(t){return c(t).then(function(t){return t.toURL()})}function w(t,e){return e=e||"readAsText",c(t).then(function(t){return new x(function(n,o){t.file(function(t){var o=new FileReader;o.onloadend=function(){n(this.result)},o[e](t)},o)})})}function v(t){return w(t,"readAsDataURL")}function y(t){return w(t).then(JSON.parse)}function m(t,e,o){return u(n(t)).then(function(){return c(t,{create:!0})}).then(function(t){return new x(function(n,r){t.createWriter(function(t){t.onwriteend=n,t.onerror=r,"string"==typeof e?e=new Blob([e],{type:o||"text/plain"}):e instanceof Blob!=!0&&(e=new Blob([JSON.stringify(e,null,4)],{type:o||"application/json"})),t.write(e)},r)})})}function _(t,e){return u(n(e)).then(function(n){return c(t).then(function(t){return new x(function(r,i){t.moveTo(n,o(e),r,i)})})})}function g(t,e){return u(n(e)).then(function(n){return c(t).then(function(t){return new x(function(r,i){t.copyTo(n,o(e),r,i)})})})}function R(t,e){var n=e?c:d;return new x(function(e,o){n(t).then(function(t){t!==!1?t.remove(e,o):e(1)},o)}).then(function(t){return 1===t?!1:!0})}function b(t){return f(t).then(function(t){return new x(function(e,n){t.removeRecursively(e,n)})})}function S(){for(;i.length>0&&a<t.concurrency;){a++;var e=i.pop(),n=e.shift(),o=e.shift(),r=e.shift(),s=e.shift(),u=e.shift(),c=e.shift(),f=e.shift(),l=e.shift();n._aborted?a--:o?(n.download.call(n,r,s,u,c,f,l),n.onprogress&&n.onprogress(new ProgressEvent)):n.upload.call(n,s,r,u,c,l,f)}}function U(t){return a--,S(),t}function D(e,n,o,r,s){"function"==typeof r&&(s=r,r={}),n=encodeURI(n),F&&(o=E(o)),r=r||{},r.retry&&r.retry.length||(r.retry=t.retry),r.retry=r.retry.concat();var u=new FileTransfer;s=s||r.onprogress,"function"==typeof s&&(u.onprogress=s);var c=new x(function(t,s){var c=function(a){if(0===r.retry.length)s(a);else{i.unshift([u,e,n,o,t,c,r.trustAllHosts||!1,r]);var f=r.retry.shift();f>0?setTimeout(U,f):U()}};r.retry.unshift(0),a++,c()});return c.then(U,U),c.progress=function(t){return u.onprogress=t,c},c.abort=function(){return u._aborted=!0,u.abort(),c},c}function L(t,e,n,o){return D(!0,t,e,n,o)}function M(t,e,n,o){return D(!1,e,t,n,o)}var x=t.Promise||window.Promise;if(!x)throw new Error("No Promise library given in options.Promise");this.options=t=t||{},t.persistent=void 0!==t.persistent?t.persistent:!0,t.storageSize=t.storageSize||20971520,t.concurrency=t.concurrency||3,t.retry=t.retry||[];var C,F="undefined"!=typeof cordova;F?C=new x(function(t,e){document.addEventListener("deviceready",t,!1),setTimeout(function(){e(new Error("deviceready has not fired after 5 seconds."))},5100)}):(C=s(!0),"undefined"!=typeof webkitRequestFileSystem?(window.requestFileSystem=webkitRequestFileSystem,window.FileTransfer=function(){},FileTransfer.prototype.download=function(t,e,n,o){var r=new XMLHttpRequest;return r.open("GET",t),r.responseType="blob",r.onreadystatechange=function(){4==r.readyState&&(200===r.status?m(e,r.response).then(n,o):o(r.status))},r.send(),r},window.ProgressEvent=function(){},window.FileEntry=function(){}):window.requestFileSystem=function(t,e,n,o){o(new Error("requestFileSystem not supported!"))});var B=new x(function(e,n){C.then(function(){var o=t.persistent?1:0;"number"==typeof t.fileSystem&&(o=t.fileSystem),!F&&o>1&&(console.warn('Chrome does not support fileSystem "'+o+'". Falling back on "0" (temporary).'),o=0),window.requestFileSystem(o,t.storageSize,e,n),setTimeout(function(){n(new Error("Could not retrieve FileSystem after 5 seconds."))},5100)},n)});B.then(function(t){window.__fs=t},function(t){console.error("Could not get Cordova FileSystem:",t)});var O,E;return F?(E=function(e){return e=r(e),"cdvfile://localhost/"+(t.persistent?"persistent/":"temporary/")+e},O=function(t){return c(t).then(function(t){return t.toInternalURL()})}):(E=function(e){return e=r(e),"filesystem:"+location.origin+(t.persistent?"/persistent/":"/temporary/")+e},O=function(t){return c(t).then(function(t){return t.toURL()})}),{fs:B,normalize:r,file:c,filename:o,dir:f,dirname:n,create:h,read:w,readJSON:y,write:m,move:_,copy:g,remove:R,removeDir:b,list:l,ensure:u,exists:d,download:L,upload:M,toURL:p,isCordova:F,toInternalURLSync:E,toInternalURL:O,toDataURL:v,deviceready:C,options:t,Promise:x}}},function(t){!function(e,n){function o(t,e){return(typeof e)[0]==t}function r(t,a){return a=function s(u,c,f,l,d,h){function p(t){return function(e){d&&(d=0,s(o,t,e))}}if(l=s.q,u!=o)return r(function(t,e){l.push({p:this,r:t,j:e,1:u,0:c})});if(f&&o(e,f)|o(n,f))try{d=f.then}catch(t){c=0,f=t}if(o(e,d))try{d.call(f,p(1),c=p(0))}catch(t){c(t)}else for(a=function(n,a){return o(e,n=c?n:a)?r(function(t,e){i(this,t,e,f,n)}):t},h=0;h<l.length;)d=l[h++],o(e,u=d[c])?i(d.p,d.r,d.j,f,u):(c?d.r:d.j)(f)},a.q=[],t.call(t={then:function(t,e){return a(t,e)},catch:function(t){return a(0,t)}},function(t){a(o,1,t)},function(t){a(o,0,t)}),t}function i(t,r,i,a,s){setImmediate(function(){try{a=s(a),s=a&&o(n,a)|o(e,a)&&a.then,o(e,s)?a==t?i(TypeError()):s.call(a,r,i):r(a)}catch(t){i(t)}})}function a(t){return r(function(e){e(t)})}t.exports=r,r.resolve=a,r.reject=function(t){return r(function(e,n){n(t)})},r.all=function(t){return r(function(e,n,o,r){r=[],o=t.length||e(r),t.map(function(t,i){a(t).then(function(t){r[i]=t,--o||e(r)},n)})})}}("f","o")},function(t){function e(t,e){var n,o,r,i,a,s,u,c;for(n=3&t.length,o=t.length-n,r=e,a=3432918353,s=461845907,c=0;o>c;)u=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,r^=u,r=r<<13|r>>>19,i=5*(65535&r)+((5*(r>>>16)&65535)<<16)&4294967295,r=(65535&i)+27492+(((i>>>16)+58964&65535)<<16);switch(u=0,n){case 3:u^=(255&t.charCodeAt(c+2))<<16;case 2:u^=(255&t.charCodeAt(c+1))<<8;case 1:u^=255&t.charCodeAt(c),u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,r^=u}return r^=t.length,r^=r>>>16,r=2246822507*(65535&r)+((2246822507*(r>>>16)&65535)<<16)&4294967295,r^=r>>>13,r=3266489909*(65535&r)+((3266489909*(r>>>16)&65535)<<16)&4294967295,r^=r>>>16,r>>>0}t.exports=e}]);
!function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){window.CordovaAppLoader=n(1),window.CordovaFileCache=n(2),window.CordovaPromiseFS=n(3),window.Promise=n(4),window.setImmediate=window.setTimeout},function(t,e,n){function o(t){if(!t)throw new Error("CordovaAppLoader has no options!");if(!t.fs)throw new Error('CordovaAppLoader has no "fs" option (cordova-promise-fs)');if(!t.serverRoot)throw new Error('CordovaAppLoader has no "serverRoot" option.');if(!window.pegasus||!window.Manifest)throw new Error("CordovaAppLoader bootstrap.js is missing.");this.allowServerRootFromManifest=t.allowServerRootFromManifest===!0,i=t.fs.Promise,this.manifest=window.Manifest,this.newManifest=null,this.bundledManifest=null,this._lastUpdateFiles=localStorage.getItem("last_update_files"),t.serverRoot=t.serverRoot||"",t.serverRoot&&"/"!==t.serverRoot[t.serverRoot.length-1]&&(t.serverRoot+="/"),this.newManifestUrl=t.manifestUrl||t.serverRoot+(t.manifest||"manifest.json"),t.mode&&(t.mode="mirror"),this.cache=new r(t),this.corruptNewManifest=!1,this._toBeCopied=[],this._toBeDeleted=[],this._toBeDownloaded=[],this._updateReady=!1,this._checkTimeout=t.checkTimeout||1e4}var r=n(2),i=(n(3),null),a=location.href.replace(location.hash,"");a=a.substr(0,a.lastIndexOf("/")+1),/ip(hone|ad|od)/i.test(navigator.userAgent)&&(a=location.pathname.substr(location.pathname.indexOf("/www/")),a=a.substr(0,a.lastIndexOf("/")+1),a="cdvfile://localhost/bundle"+a),o.prototype._createFilemap=function(t){var e={},n=this.cache._fs.normalize;return Object.keys(t).forEach(function(o){t[o].filename=n(t[o].filename),e[t[o].filename]=t[o]}),e},o.prototype.copyFromBundle=function(t){var e=a+t;return this.cache._fs.download(e,this.cache.localRoot+t)},o.prototype.getBundledManifest=function(){var t=this,e=document.querySelector("script[manifest]"),n=(e?e.getAttribute("manifest"):null)||"manifest.json";return new i(function(e,o){t.bundledManifest?e(t.bundledManifest):(pegasus(n).then(function(n){t.bundledManifest=n,e(n)},o),setTimeout(function(){o(new Error("bundled manifest timeout"))},t._checkTimeout))})},o.prototype.check=function(t){var e=this,n=this.manifest;"string"==typeof t&&(e.newManifestUrl=t,t=void 0);var o=new i(function(n,o){"object"==typeof t?n(t):(pegasus(e.newManifestUrl).then(n,o),setTimeout(function(){o(new Error("new manifest timeout"))},e._checkTimeout))});return new i(function(t,r){i.all([o,e.getBundledManifest(),e.cache.list()]).then(function(o){var i=o[0],a=o[1];if(JSON.stringify(i.files)===e._lastUpdateFiles)return JSON.stringify(i.files)!==JSON.stringify(Manifest.files)&&(console.warn("New manifest available, but an earlier update attempt failed. Will not download."),e.corruptNewManifest=!0,t(null)),void t(!1);if(!i.files)return void r('Downloaded Manifest has no "files" attribute.');var s=o[2],u=e._createFilemap(n.files),c=e._createFilemap(i.files),f=e._createFilemap(a.files);e._toBeDownloaded=[],e._toBeCopied=[],e._toBeDeleted=[];var l=e.cache._fs.isCordova;Object.keys(c).filter(function(t){return!u[t]||u[t].version!==c[t].version||!e.cache.isCached(t)}).forEach(function(t){l&&f[t]&&f[t].version===c[t].version?e._toBeCopied.push(t):e._toBeDownloaded.push(t)}),e._toBeDeleted=s.map(function(t){return t.substr(e.cache.localRoot.length)}).filter(function(t){return!c[t]||e._toBeDownloaded.indexOf(t)>=0||e._toBeCopied.indexOf(t)>=0});var d=e._toBeDeleted.length+e._toBeDownloaded.length;d>0?(e.newManifest=i,e.newManifest.root=e.cache.localInternalURL,t(!0)):t(!1)},function(t){r(t)})})},o.prototype.canDownload=function(){return!!this.newManifest&&!this._updateReady},o.prototype.canUpdate=function(){return this._updateReady},o.prototype.download=function(t){var e=this;return e.canDownload()?(localStorage.removeItem("manifest"),localStorage.setItem("last_update_files",JSON.stringify(this.newManifest.files)),this.manifest.files=Manifest.files={},e.cache.remove(e._toBeDeleted,!0).then(function(){return i.all(e._toBeCopied.map(function(t){return e.cache._fs.download(a+t,e.cache.localRoot+t)}))}).then(function(){return e.allowServerRootFromManifest&&e.newManifest.serverRoot&&(e.cache.serverRoot=e.newManifest.serverRoot),e.cache.add(e._toBeDownloaded),e.cache.download(t)}).then(function(){return e._toBeDeleted=[],e._toBeDownloaded=[],e._updateReady=!0,e.newManifest},function(t){return t&&t.length&&e.cache.remove(t),t})):new i(function(t){t(null)})},o.prototype.update=function(t){return this._updateReady?(localStorage.setItem("manifest",JSON.stringify(this.newManifest)),t!==!1&&location.reload(),!0):!1},o.prototype.clear=function(){return localStorage.removeItem("last_update_files"),localStorage.removeItem("manifest"),this.cache.clear()},o.prototype.reset=function(){return this.clear().then(function(){location.reload()},function(){location.reload()})},t.exports=o},function(t,e,n){function o(t){var e=this;if(this._fs=t.fs,!this._fs)throw new Error('Missing required option "fs". Add an instance of cordova-promise-fs.');i=this._fs.Promise,this._mirrorMode="hash"!==t.mode,this._retry=t.retry||[500,1500,8e3],this._cacheBuster=!!t.cacheBuster,this.localRoot=this._fs.normalize(t.localRoot||"data"),this.serverRoot=this._fs.normalize(t.serverRoot||""),this._downloading=[],this._added=[],this._cached={},this.ready=this._fs.ensure(this.localRoot).then(function(t){return e.localInternalURL=a?t.toInternalURL():t.toURL(),e.localUrl=t.toURL(),e.list()})}var r=n(5),i=null,a="undefined"!=typeof cordova;o.prototype.list=function(){var t=this;return new i(function(e){t._fs.list(t.localRoot,"rfe").then(function(n){t._cached={},n=n.map(function(e){var n=t._fs.normalize(e.fullPath);return t._cached[n]={toInternalURL:a?e.toInternalURL():e.toURL(),toURL:e.toURL()},n}),e(n)},function(){e([])})})},o.prototype.add=function(t){t||(t=[]),"string"==typeof t&&(t=[t]);var e=this;return t.forEach(function(t){t=e.toServerURL(t),-1===e._added.indexOf(t)&&e._added.push(t)}),e.isDirty()},o.prototype.remove=function(t,e){t||(t=[]);var n=[];"string"==typeof t&&(t=[t]);var o=this;return t.forEach(function(t){var e=o._added.indexOf(o.toServerURL(t));e>=0&&o._added.splice(e,1);var r=o.toPath(t);n.push(o._fs.remove(r)),delete o._cached[r]}),e?i.all(n):o.isDirty()},o.prototype.getDownloadQueue=function(){var t=this,e=t._added.filter(function(e){return!t.isCached(e)});return e},o.prototype.getAdded=function(){return this._added},o.prototype.isDirty=function(){return this.getDownloadQueue().length>0},o.prototype.download=function(t){var e=this._fs,n=this;return n.abort(),new i(function(o,r){e.ensure(n.localRoot).then(function(){return n.list()}).then(function(){if(!n.isDirty())return void o(n);var i=n.getDownloadQueue(),a=[],s=n._downloading.length,u=n._downloading.length,c=n._downloading.length+i.length;i.forEach(function(i){var f,l=n.toPath(i);"function"==typeof t&&(f=function(e){e.queueIndex=s,e.queueSize=c,e.url=i,e.path=l,e.percentage=s/c,e.loaded>0&&e.total>0&&s!==c&&(e.percentage+=e.loaded/e.total/c),a.indexOf(i)<0&&(a.push(i),s++),t(e)});var d=function(){u++,u===c&&(n._downloading=[],n.list().then(function(){f&&f(new ProgressEvent),n.isDirty()?r(n.getDownloadQueue()):o(n)},r))},h=i;n._cacheBuster&&(h+="?"+Date.now());var p=e.download(h,l,{retry:n._retry},f);p.then(d,d),n._downloading.push(p)})},r)})},o.prototype.abort=function(){this._downloading.forEach(function(t){t.abort()}),this._downloading=[]},o.prototype.isCached=function(t){return t=this.toPath(t),!!this._cached[t]},o.prototype.clear=function(){var t=this;return this._cached={},this._fs.removeDir(this.localRoot).then(function(){return t._fs.ensure(t.localRoot)})},o.prototype.toInternalURL=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toInternalURL:t},o.prototype.get=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toInternalURL:this.toServerURL(t)},o.prototype.toDataURL=function(t){return this._fs.toDataURL(this.toPath(t))},o.prototype.toURL=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toURL:t},o.prototype.toServerURL=function(t){return t=this._fs.normalize(t),t.indexOf("://")<0?this.serverRoot+t:t},o.prototype.toPath=function(t){if(this._mirrorMode){var e=t.indexOf("?");return e>-1&&(t=t.substr(0,e)),t=t=this._fs.normalize(t||""),len=this.serverRoot.length,t.substr(0,len)!==this.serverRoot?this.localRoot+t:this.localRoot+t.substr(len)}return this.localRoot+r(t)+t.substr(t.lastIndexOf("."))},t.exports=o},function(t){function e(t,n,o,r){t.getDirectory(n[0],{create:!0},function(t){n.length>1?e(t,n.slice(1),o,r):o(t)},r)}function n(t){return t=t.substr(0,t.lastIndexOf("/")+1),"/"===t[0]&&(t=t.substr(1)),t}function o(t){return t.substr(t.lastIndexOf("/")+1)}function r(t){return t=t||"","/"===t[0]&&(t=t.substr(1)),t&&t.indexOf(".")<0&&"/"!==t[t.length-1]&&(t+="/"),"./"===t&&(t=""),t}var i=[],a=0;t.exports=function(t){function s(t){return new U(function(e){return e(t)})}function u(t){return new U(function(n,o){return F.then(function(r){t?(t=t.split("/").filter(function(t){return t&&t.length>0&&"."!==t&&".."!==t}),e(r.root,t,n,o)):n(r.root)},o)})}function c(t,e){return new U(function(n,o){return"object"==typeof t?n(t):(t=r(t),e=e||{},F.then(function(r){r.root.getFile(t,e,n,o)},o))})}function f(t,e){return t=r(t),e=e||{},new U(function(n,o){return F.then(function(r){t&&"/"!==t?r.root.getDirectory(t,e,n,o):n(r.root)},o)})}function l(t,e){e=e||"";var n=e.indexOf("r")>-1,o=e.indexOf("e")>-1,r=e.indexOf("f")>-1,i=e.indexOf("d")>-1;return r&&i&&(r=!1,i=!1),new U(function(e,a){return f(t).then(function(t){var u=t.createReader();u.readEntries(function(t){var u=[s(t)];n&&t.filter(function(t){return t.isDirectory}).forEach(function(t){u.push(l(t.fullPath,"re"))}),U.all(u).then(function(t){var n=[];n=n.concat.apply(n,t),r&&(n=n.filter(function(t){return t.isFile})),i&&(n=n.filter(function(t){return t.isDirectory})),o||(n=n.map(function(t){return t.fullPath})),e(n)},a)},a)},a)})}function d(t){return new U(function(e,n){c(t).then(function(t){e(t)},function(t){1===t.code?e(!1):n(t)})})}function h(t){return u(n(t)).then(function(){return c(t,{create:!0})})}function p(t){return c(t).then(function(t){return t.toURL()})}function w(t,e){return e=e||"readAsText",c(t).then(function(t){return new U(function(n,o){t.file(function(t){var o=new FileReader;o.onloadend=function(){n(this.result)},o[e](t)},o)})})}function m(t){return w(t,"readAsDataURL")}function v(t){return w(t).then(JSON.parse)}function y(t,e,o){return u(n(t)).then(function(){return c(t,{create:!0})}).then(function(t){return new U(function(n,r){t.createWriter(function(t){t.onwriteend=n,t.onerror=r,"string"==typeof e?e=new Blob([e],{type:o||"text/plain"}):e instanceof Blob!=!0&&(e=new Blob([JSON.stringify(e,null,4)],{type:o||"application/json"})),t.write(e)},r)})})}function _(t,e){return u(n(e)).then(function(n){return c(t).then(function(t){return new U(function(r,i){t.moveTo(n,o(e),r,i)})})})}function g(t,e){return u(n(e)).then(function(n){return c(t).then(function(t){return new U(function(r,i){t.copyTo(n,o(e),r,i)})})})}function R(t,e){var n=e?c:d;return new U(function(e,o){n(t).then(function(t){t!==!1?t.remove(e,o):e(1)},o)}).then(function(t){return 1===t?!1:!0})}function b(t){return f(t).then(function(t){return new U(function(e,n){t.removeRecursively(e,n)})})}function S(){for(;i.length>0&&a<t.concurrency;){a++;var e=i.pop(),n=e.shift(),o=e.shift(),r=e.shift(),s=e.shift(),u=e.shift(),c=e.shift(),f=e.shift(),l=e.shift();n._aborted?a--:o?(n.download.call(n,r,s,u,c,f,l),n.onprogress&&n.onprogress(new ProgressEvent)):n.upload.call(n,s,r,u,c,l,f)}}function L(t){return a--,S(),t}function T(e,n,r,s,u){"function"==typeof s&&(u=s,s={}),M&&r.indexOf("://")<0&&(r=C(r)),s=s||{},s.retry&&s.retry.length||(s.retry=t.retry),s.retry=s.retry.concat(),s.file||e||(s.fileName=o(r));var c=new FileTransfer;u=u||s.onprogress,"function"==typeof u&&(c.onprogress=u);var f=new U(function(t,o){var u=function(a){if(0===s.retry.length)o(a);else{i.unshift([c,e,n,r,t,u,s.trustAllHosts||!1,s]);var f=s.retry.shift();f>0?setTimeout(L,f):L()}};s.retry.unshift(0),a++,u()});return f.then(L,L),f.progress=function(t){return c.onprogress=t,f},f.abort=function(){return c._aborted=!0,c.abort(),f},f}function I(t,e,n,o){return T(!0,t,e,n,o)}function x(t,e,n,o){return T(!1,e,t,n,o)}var U=t.Promise||window.Promise;if("undefined"==typeof U)throw new Error("No Promise library given in options.Promise");this.options=t=t||{},t.persistent=void 0!==t.persistent?t.persistent:!0,t.storageSize=t.storageSize||20971520,t.concurrency=t.concurrency||3,t.retry=t.retry||[];var D,M="undefined"!=typeof cordova;M?D=new U(function(t,e){document.addEventListener("deviceready",t,!1),setTimeout(function(){e(new Error("deviceready has not fired after 5 seconds."))},5100)}):(D=s(!0),"undefined"!=typeof webkitRequestFileSystem?(window.requestFileSystem=webkitRequestFileSystem,window.FileTransfer=function(){},FileTransfer.prototype.download=function(t,e,n,o){var r=new XMLHttpRequest;return r.open("GET",t),r.responseType="blob",r.onreadystatechange=function(){4==r.readyState&&(200===r.status?y(e,r.response).then(n,o):o(r.status))},r.send(),r},window.ProgressEvent=function(){},window.FileEntry=function(){}):window.requestFileSystem=function(t,e,n,o){o(new Error("requestFileSystem not supported!"))});var F=new U(function(e,n){D.then(function(){var o=t.persistent?1:0;"number"==typeof t.fileSystem&&(o=t.fileSystem),!M&&o>1&&(console.warn('Chrome does not support fileSystem "'+o+'". Falling back on "0" (temporary).'),o=0),window.requestFileSystem(o,t.storageSize,e,n),setTimeout(function(){n(new Error("Could not retrieve FileSystem after 5 seconds."))},5100)},n)});F.then(function(t){window.__fs=t},function(t){console.error("Could not get Cordova FileSystem:",t)});var O,C;return M?(C=function(e){return e=r(e),e.indexOf("://")<0?"cdvfile://localhost/"+(t.persistent?"persistent/":"temporary/")+e:e},O=function(t){return c(t).then(function(t){return t.toInternalURL()})}):(C=function(e){return e=r(e),"filesystem:"+location.origin+(t.persistent?"/persistent/":"/temporary/")+e},O=function(t){return c(t).then(function(t){return t.toURL()})}),{fs:F,normalize:r,file:c,filename:o,dir:f,dirname:n,create:h,read:w,readJSON:v,write:y,move:_,copy:g,remove:R,removeDir:b,list:l,ensure:u,exists:d,download:I,upload:x,toURL:p,isCordova:M,toInternalURLSync:C,toInternalURL:O,toDataURL:m,deviceready:D,options:t,Promise:U}}},function(t,e,n){(function(e){!function(n,o){function r(t,e){return(typeof e)[0]==t}function i(t,e){return e=function s(u,c,f,l,d,h){function p(t){return function(e){d&&(d=0,s(r,t,e))}}if(l=s.q,u!=r)return i(function(t,e){l.push({p:this,r:t,j:e,1:u,0:c})});if(f&&r(n,f)|r(o,f))try{d=f.then}catch(t){c=0,f=t}if(r(n,d))try{d.call(f,p(1),c=p(0))}catch(t){c(t)}else for(e=function(e,o){return r(n,e=c?e:o)?i(function(t,n){a(this,t,n,f,e)}):t},h=0;h<l.length;)d=l[h++],r(n,u=d[c])?a(d.p,d.r,d.j,f,u):(c?d.r:d.j)(f)},e.q=[],t.call(t={then:function(t,n){return e(t,n)},catch:function(t){return e(0,t)}},function(t){e(r,1,t)},function(t){e(r,0,t)}),t}function a(t,i,a,s,u){e(function(){try{s=u(s),u=s&&r(o,s)|r(n,s)&&s.then,r(n,u)?s==t?a(TypeError()):u.call(s,i,a):i(s)}catch(t){a(t)}})}function s(t){return i(function(e){e(t)})}t.exports=i,i.resolve=s,i.reject=function(t){return i(function(e,n){n(t)})},i.all=function(t){return i(function(e,n,o,r){r=[],o=t.length||e(r),t.map(function(t,i){s(t).then(function(t){r[i]=t,--o||e(r)},n)})})}}("f","o")}).call(e,n(6).setImmediate)},function(t){function e(t,e){var n,o,r,i,a,s,u,c;for(n=3&t.length,o=t.length-n,r=e,a=3432918353,s=461845907,c=0;o>c;)u=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,r^=u,r=r<<13|r>>>19,i=5*(65535&r)+((5*(r>>>16)&65535)<<16)&4294967295,r=(65535&i)+27492+(((i>>>16)+58964&65535)<<16);switch(u=0,n){case 3:u^=(255&t.charCodeAt(c+2))<<16;case 2:u^=(255&t.charCodeAt(c+1))<<8;case 1:u^=255&t.charCodeAt(c),u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,r^=u}return r^=t.length,r^=r>>>16,r=2246822507*(65535&r)+((2246822507*(r>>>16)&65535)<<16)&4294967295,r^=r>>>13,r=3266489909*(65535&r)+((3266489909*(r>>>16)&65535)<<16)&4294967295,r^=r>>>16,r>>>0}t.exports=e},function(t,e,n){(function(t,o){function r(t,e){this._id=t,this._clearFn=e}var i=n(7).nextTick,a=Function.prototype.apply,s=Array.prototype.slice,u={},c=0;e.setTimeout=function(){return new r(a.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new r(a.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},e.setImmediate="function"==typeof t?t:function(t){var n=c++,o=arguments.length<2?!1:s.call(arguments,1);return u[n]=!0,i(function(){u[n]&&(o?t.apply(null,o):t.call(null),e.clearImmediate(n))}),n},e.clearImmediate="function"==typeof o?o:function(t){delete u[t]}}).call(e,n(6).setImmediate,n(6).clearImmediate)},function(t){function e(){if(!i){i=!0;for(var t,e=r.length;e;){t=r,r=[];for(var n=-1;++n<e;)t[n]();e=r.length}i=!1}}function n(){}var o=t.exports={},r=[],i=!1;o.nextTick=function(t){r.push(t),i||setTimeout(e,0)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=n,o.addListener=n,o.once=n,o.off=n,o.removeListener=n,o.removeAllListeners=n,o.emit=n,o.binding=function(){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}}]);

@@ -5,10 +5,10 @@ var CordovaAppLoader =

/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -20,23 +20,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports

@@ -50,4 +50,4 @@ /******/ return __webpack_require__(0);

var CordovaFileCache = __webpack_require__(2);
var CordovaPromiseFS = __webpack_require__(1);
var CordovaFileCache = __webpack_require__(1);
var CordovaPromiseFS = __webpack_require__(2);
var Promise = null;

@@ -227,2 +227,4 @@

}
}, function(err){
reject(err);
}); // end of .then

@@ -243,3 +245,3 @@ }); // end of new Promise

if(!self.canDownload()) {
return Promise.resolve(null);
return new Promise(function(resolve){ resolve(null); });
}

@@ -307,3 +309,265 @@ // we will delete files, which will invalidate the current manifest...

var hash = __webpack_require__(3);
var Promise = null;
var isCordova = typeof cordova !== 'undefined';
/* Cordova File Cache x */
function FileCache(options){
var self = this;
// cordova-promise-fs
this._fs = options.fs;
if(!this._fs) {
throw new Error('Missing required option "fs". Add an instance of cordova-promise-fs.');
}
// Use Promises from fs.
Promise = this._fs.Promise;
// 'mirror' mirrors files structure from "serverRoot" to "localRoot"
// 'hash' creates a 1-deep filestructure, where the filenames are hashed server urls (with extension)
this._mirrorMode = options.mode !== 'hash';
this._retry = options.retry || [500,1500,8000];
this._cacheBuster = !!options.cacheBuster;
// normalize path
this.localRoot = this._fs.normalize(options.localRoot || 'data');
this.serverRoot = this._fs.normalize(options.serverRoot || '');
// set internal variables
this._downloading = []; // download promises
this._added = []; // added files
this._cached = {}; // cached files
// list existing cache contents
this.ready = this._fs.ensure(this.localRoot)
.then(function(entry){
self.localInternalURL = isCordova? entry.toInternalURL(): entry.toURL();
self.localUrl = entry.toURL();
return self.list();
});
}
/**
* Helper to cache all 'internalURL' and 'URL' for quick synchronous access
* to the cached files.
*/
FileCache.prototype.list = function list(){
var self = this;
return new Promise(function(resolve,reject){
self._fs.list(self.localRoot,'rfe').then(function(entries){
self._cached = {};
entries = entries.map(function(entry){
var fullPath = self._fs.normalize(entry.fullPath);
self._cached[fullPath] = {
toInternalURL: isCordova? entry.toInternalURL(): entry.toURL(),
toURL: entry.toURL(),
};
return fullPath;
});
resolve(entries);
},function(){
resolve([]);
});
});
};
FileCache.prototype.add = function add(urls){
if(!urls) urls = [];
if(typeof urls === 'string') urls = [urls];
var self = this;
urls.forEach(function(url){
url = self.toServerURL(url);
if(self._added.indexOf(url) === -1) {
self._added.push(url);
}
});
return self.isDirty();
};
FileCache.prototype.remove = function remove(urls,returnPromises){
if(!urls) urls = [];
var promises = [];
if(typeof urls === 'string') urls = [urls];
var self = this;
urls.forEach(function(url){
var index = self._added.indexOf(self.toServerURL(url));
if(index >= 0) self._added.splice(index,1);
var path = self.toPath(url);
promises.push(self._fs.remove(path));
delete self._cached[path];
});
return returnPromises? Promise.all(promises): self.isDirty();
};
FileCache.prototype.getDownloadQueue = function(){
var self = this;
var queue = self._added.filter(function(url){
return !self.isCached(url);
});
return queue;
};
FileCache.prototype.getAdded = function() {
return this._added;
};
FileCache.prototype.isDirty = function isDirty(){
return this.getDownloadQueue().length > 0;
};
FileCache.prototype.download = function download(onprogress){
var fs = this._fs;
var self = this;
self.abort();
return new Promise(function(resolve,reject){
// make sure cache directory exists and that
// we have retrieved the latest cache contents
// to avoid downloading files we already have!
fs.ensure(self.localRoot).then(function(){
return self.list();
}).then(function(){
// no dowloads needed, resolve
if(!self.isDirty()) {
resolve(self);
return;
}
// keep track of number of downloads!
var queue = self.getDownloadQueue();
var started = [];
var index = self._downloading.length;
var done = self._downloading.length;
var total = self._downloading.length + queue.length;
// download every file in the queue (which is the diff from _added with _cached)
queue.forEach(function(url){
var path = self.toPath(url);
// augment progress event with index/total stats
var onSingleDownloadProgress;
if(typeof onprogress === 'function') {
onSingleDownloadProgress = function(ev){
ev.queueIndex = index;
ev.queueSize = total;
ev.url = url;
ev.path = path;
ev.percentage = index / total;
if(ev.loaded > 0 && ev.total > 0 && index !== total){
ev.percentage += (ev.loaded / ev.total) / total;
}
if(started.indexOf(url) < 0) {
started.push(url);
index++;
}
onprogress(ev);
};
}
// callback
var onDone = function(){
done++;
// when we're done
if(done === total) {
// reset downloads
self._downloading = [];
// check if we got everything
self.list().then(function(){
// final progress event!
if(onSingleDownloadProgress) onSingleDownloadProgress(new ProgressEvent());
// Yes, we're not dirty anymore!
if(!self.isDirty()) {
resolve(self);
// Aye, some files got left behind!
} else {
reject(self.getDownloadQueue());
}
},reject);
}
};
var downloadUrl = url;
if(self._cacheBuster) downloadUrl += "?"+Date.now();
var download = fs.download(downloadUrl,path,{retry:self._retry},onSingleDownloadProgress);
download.then(onDone,onDone);
self._downloading.push(download);
});
},reject);
});
};
FileCache.prototype.abort = function abort(){
this._downloading.forEach(function(download){
download.abort();
});
this._downloading = [];
};
FileCache.prototype.isCached = function isCached(url){
url = this.toPath(url);
return !!this._cached[url];
};
FileCache.prototype.clear = function clear(){
var self = this;
this._cached = {};
return this._fs.removeDir(this.localRoot).then(function(){
return self._fs.ensure(self.localRoot);
});
};
/**
* Helpers to output to various formats
*/
FileCache.prototype.toInternalURL = function toInternalURL(url){
path = this.toPath(url);
if(this._cached[path]) return this._cached[path].toInternalURL;
return url;
};
FileCache.prototype.get = function get(url){
path = this.toPath(url);
if(this._cached[path]) return this._cached[path].toInternalURL;
return this.toServerURL(url);
};
FileCache.prototype.toDataURL = function toDataURL(url){
return this._fs.toDataURL(this.toPath(url));
};
FileCache.prototype.toURL = function toURL(url){
path = this.toPath(url);
return this._cached[path]? this._cached[path].toURL: url;
};
FileCache.prototype.toServerURL = function toServerURL(path){
path = this._fs.normalize(path);
return path.indexOf('://') < 0? this.serverRoot + path: path;
};
/**
* Helper to transform remote URL to a local path (for cordova-promise-fs)
*/
FileCache.prototype.toPath = function toPath(url){
if(this._mirrorMode) {
var query = url.indexOf('?');
if(query > -1){
url = url.substr(0,query);
}
url = url = this._fs.normalize(url || '');
len = this.serverRoot.length;
if(url.substr(0,len) !== this.serverRoot) {
return this.localRoot + url;
} else {
return this.localRoot + url.substr(len);
}
} else {
return this.localRoot + hash(url) + url.substr(url.lastIndexOf('.'));
}
};
module.exports = FileCache;
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
/**
* Static Private functions

@@ -351,3 +615,3 @@ */

var Promise = options.Promise || window.Promise;
if(!Promise) { throw new Error("No Promise library given in options.Promise"); }
if(typeof Promise === 'undefined') { throw new Error("No Promise library given in options.Promise"); }

@@ -438,3 +702,3 @@ /* default options */

folders = folders.split('/').filter(function(folder) {
return folder && folder.length > 0 && folder[0] !== '.';
return folder && folder.length > 0 && folder !== '.' && folder !== '..';
});

@@ -550,3 +814,3 @@ __createDir(fs.root,folders,resolve,reject);

path = normalize(path);
return 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path;
return path.indexOf('://') < 0? 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path: path;
};

@@ -711,4 +975,3 @@

}
serverUrl = encodeURI(serverUrl);
if(isCordova) localPath = toInternalURLSync(localPath);
if(isCordova && localPath.indexOf('://') < 0) localPath = toInternalURLSync(localPath);

@@ -720,2 +983,5 @@ transferOptions = transferOptions || {};

transferOptions.retry = transferOptions.retry.concat();
if(!transferOptions.file && !isDownload){
transferOptions.fileName = filename(localPath);
}

@@ -795,260 +1061,3 @@ var ft = new FileTransfer();

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
var hash = __webpack_require__(3);
var Promise = null;
var isCordova = typeof cordova !== 'undefined';
/* Cordova File Cache x */
function FileCache(options){
var self = this;
// cordova-promise-fs
this._fs = options.fs;
if(!this._fs) {
throw new Error('Missing required option "fs". Add an instance of cordova-promise-fs.');
}
// Use Promises from fs.
Promise = this._fs.Promise;
// 'mirror' mirrors files structure from "serverRoot" to "localRoot"
// 'hash' creates a 1-deep filestructure, where the filenames are hashed server urls (with extension)
this._mirrorMode = options.mode !== 'hash';
this._retry = options.retry || [500,1500,8000];
this._cacheBuster = !!options.cacheBuster;
// normalize path
this.localRoot = this._fs.normalize(options.localRoot || 'data');
this.serverRoot = this._fs.normalize(options.serverRoot || '');
// set internal variables
this._downloading = []; // download promises
this._added = []; // added files
this._cached = {}; // cached files
// list existing cache contents
this.ready = this._fs.ensure(this.localRoot)
.then(function(entry){
self.localInternalURL = isCordova? entry.toInternalURL(): entry.toURL();
self.localUrl = entry.toURL();
return self.list();
});
}
/**
* Helper to cache all 'internalURL' and 'URL' for quick synchronous access
* to the cached files.
*/
FileCache.prototype.list = function list(){
var self = this;
return new Promise(function(resolve,reject){
self._fs.list(self.localRoot,'rfe').then(function(entries){
self._cached = {};
entries = entries.map(function(entry){
var fullPath = self._fs.normalize(entry.fullPath);
self._cached[fullPath] = {
toInternalURL: isCordova? entry.toInternalURL(): entry.toURL(),
toURL: entry.toURL(),
};
return fullPath;
});
resolve(entries);
},function(){
resolve([]);
});
});
};
FileCache.prototype.add = function add(urls){
if(!urls) urls = [];
if(typeof urls === 'string') urls = [urls];
var self = this;
urls.forEach(function(url){
url = self.toServerURL(url);
if(self._added.indexOf(url) === -1) {
self._added.push(url);
}
});
return self.isDirty();
};
FileCache.prototype.remove = function remove(urls,returnPromises){
if(!urls) urls = [];
var promises = [];
if(typeof urls === 'string') urls = [urls];
var self = this;
urls.forEach(function(url){
var index = self._added.indexOf(self.toServerURL(url));
if(index >= 0) self._added.splice(index,1);
var path = self.toPath(url);
promises.push(self._fs.remove(path));
delete self._cached[path];
});
return returnPromises? Promise.all(promises): self.isDirty();
};
FileCache.prototype.getDownloadQueue = function(){
var self = this;
var queue = self._added.filter(function(url){
return !self.isCached(url);
});
return queue;
};
FileCache.prototype.getAdded = function() {
return this._added;
};
FileCache.prototype.isDirty = function isDirty(){
return this.getDownloadQueue().length > 0;
};
FileCache.prototype.download = function download(onprogress){
var fs = this._fs;
var self = this;
self.abort();
return new Promise(function(resolve,reject){
// make sure cache directory exists and that
// we have retrieved the latest cache contents
// to avoid downloading files we already have!
fs.ensure(self.localRoot).then(function(){
return self.list();
}).then(function(){
// no dowloads needed, resolve
if(!self.isDirty()) {
resolve(self);
return;
}
// keep track of number of downloads!
var queue = self.getDownloadQueue();
var started = [];
var index = self._downloading.length;
var done = self._downloading.length;
var total = self._downloading.length + queue.length;
// download every file in the queue (which is the diff from _added with _cached)
queue.forEach(function(url){
var path = self.toPath(url);
// augment progress event with index/total stats
var onSingleDownloadProgress;
if(typeof onprogress === 'function') {
onSingleDownloadProgress = function(ev){
ev.queueIndex = index;
ev.queueSize = total;
ev.url = url;
ev.path = path;
ev.percentage = index / total;
if(ev.loaded > 0 && ev.total > 0 && index !== total){
ev.percentage += (ev.loaded / ev.total) / total;
}
if(started.indexOf(url) < 0) {
started.push(url);
index++;
}
onprogress(ev);
};
}
// callback
var onDone = function(){
done++;
// when we're done
if(done === total) {
// reset downloads
self._downloading = [];
// check if we got everything
self.list().then(function(){
// final progress event!
if(onSingleDownloadProgress) onSingleDownloadProgress(new ProgressEvent());
// Yes, we're not dirty anymore!
if(!self.isDirty()) {
resolve(self);
// Aye, some files got left behind!
} else {
reject(self.getDownloadQueue());
}
},reject);
}
};
var downloadUrl = url;
if(self._cacheBuster) downloadUrl += "?"+Date.now();
var download = fs.download(downloadUrl,path,{retry:self._retry},onSingleDownloadProgress);
download.then(onDone,onDone);
self._downloading.push(download);
});
},reject);
});
};
FileCache.prototype.abort = function abort(){
this._downloading.forEach(function(download){
download.abort();
});
this._downloading = [];
};
FileCache.prototype.isCached = function isCached(url){
url = this.toPath(url);
return !!this._cached[url];
};
FileCache.prototype.clear = function clear(){
var self = this;
this._cached = {};
return this._fs.removeDir(this.localRoot).then(function(){
return self._fs.ensure(self.localRoot);
});
};
/**
* Helpers to output to various formats
*/
FileCache.prototype.toInternalURL = function toInternalURL(url){
path = this.toPath(url);
if(this._cached[path]) return this._cached[path].toInternalURL;
return url;
};
FileCache.prototype.get = function get(url){
path = this.toPath(url);
if(this._cached[path]) return this._cached[path].toInternalURL;
return this.toServerURL(url);
};
FileCache.prototype.toDataURL = function toDataURL(url){
return this._fs.toDataURL(this.toPath(url));
};
FileCache.prototype.toURL = function toURL(url){
path = this.toPath(url);
return this._cached[path]? this._cached[path].toURL: url;
};
FileCache.prototype.toServerURL = function toServerURL(path){
path = this._fs.normalize(path);
return path.indexOf('://') < 0? this.serverRoot + path: path;
};
/**
* Helper to transform remote URL to a local path (for cordova-promise-fs)
*/
FileCache.prototype.toPath = function toPath(url){
if(this._mirrorMode) {
url = url = this._fs.normalize(url || '');
len = this.serverRoot.length;
if(url.substr(0,len) !== this.serverRoot) {
return this.localRoot + url;
} else {
return this.localRoot + url.substr(len);
}
} else {
return this.localRoot + hash(url) + url.substr(url.lastIndexOf('.'));
}
};
module.exports = FileCache;
/***/ },

@@ -1126,2 +1135,2 @@ /* 3 */

/***/ }
/******/ ])
/******/ ]);

@@ -1,1 +0,1 @@

var CordovaAppLoader=function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){function o(t){if(!t)throw new Error("CordovaAppLoader has no options!");if(!t.fs)throw new Error('CordovaAppLoader has no "fs" option (cordova-promise-fs)');if(!t.serverRoot)throw new Error('CordovaAppLoader has no "serverRoot" option.');if(!window.pegasus||!window.Manifest)throw new Error("CordovaAppLoader bootstrap.js is missing.");this.allowServerRootFromManifest=t.allowServerRootFromManifest===!0,i=t.fs.Promise,this.manifest=window.Manifest,this.newManifest=null,this.bundledManifest=null,this._lastUpdateFiles=localStorage.getItem("last_update_files"),t.serverRoot=t.serverRoot||"",t.serverRoot&&"/"!==t.serverRoot[t.serverRoot.length-1]&&(t.serverRoot+="/"),this.newManifestUrl=t.manifestUrl||t.serverRoot+(t.manifest||"manifest.json"),t.mode&&(t.mode="mirror"),this.cache=new r(t),this.corruptNewManifest=!1,this._toBeCopied=[],this._toBeDeleted=[],this._toBeDownloaded=[],this._updateReady=!1,this._checkTimeout=t.checkTimeout||1e4}var r=n(2),i=(n(1),null),a=location.href.replace(location.hash,"");a=a.substr(0,a.lastIndexOf("/")+1),/ip(hone|ad|od)/i.test(navigator.userAgent)&&(a=location.pathname.substr(location.pathname.indexOf("/www/")),a=a.substr(0,a.lastIndexOf("/")+1),a="cdvfile://localhost/bundle"+a),o.prototype._createFilemap=function(t){var e={},n=this.cache._fs.normalize;return Object.keys(t).forEach(function(o){t[o].filename=n(t[o].filename),e[t[o].filename]=t[o]}),e},o.prototype.copyFromBundle=function(t){var e=a+t;return this.cache._fs.download(e,this.cache.localRoot+t)},o.prototype.getBundledManifest=function(){var t=this,e=document.querySelector("script[manifest]"),n=(e?e.getAttribute("manifest"):null)||"manifest.json";return new i(function(e,o){t.bundledManifest?e(t.bundledManifest):(pegasus(n).then(function(n){t.bundledManifest=n,e(n)},o),setTimeout(function(){o(new Error("bundled manifest timeout"))},t._checkTimeout))})},o.prototype.check=function(t){var e=this,n=this.manifest;"string"==typeof t&&(e.newManifestUrl=t,t=void 0);var o=new i(function(n,o){"object"==typeof t?n(t):(pegasus(e.newManifestUrl).then(n,o),setTimeout(function(){o(new Error("new manifest timeout"))},e._checkTimeout))});return new i(function(t,r){i.all([o,e.getBundledManifest(),e.cache.list()]).then(function(o){var i=o[0],a=o[1];if(JSON.stringify(i.files)===e._lastUpdateFiles)return JSON.stringify(i.files)!==JSON.stringify(Manifest.files)&&(console.warn("New manifest available, but an earlier update attempt failed. Will not download."),e.corruptNewManifest=!0,t(null)),void t(!1);if(!i.files)return void r('Downloaded Manifest has no "files" attribute.');var s=o[2],u=e._createFilemap(n.files),c=e._createFilemap(i.files),f=e._createFilemap(a.files);e._toBeDownloaded=[],e._toBeCopied=[],e._toBeDeleted=[];var l=e.cache._fs.isCordova;Object.keys(c).filter(function(t){return!u[t]||u[t].version!==c[t].version||!e.cache.isCached(t)}).forEach(function(t){l&&f[t]&&f[t].version===c[t].version?e._toBeCopied.push(t):e._toBeDownloaded.push(t)}),e._toBeDeleted=s.map(function(t){return t.substr(e.cache.localRoot.length)}).filter(function(t){return!c[t]||e._toBeDownloaded.indexOf(t)>=0||e._toBeCopied.indexOf(t)>=0});var d=e._toBeDeleted.length+e._toBeDownloaded.length;d>0?(e.newManifest=i,e.newManifest.root=e.cache.localInternalURL,t(!0)):t(!1)})})},o.prototype.canDownload=function(){return!!this.newManifest&&!this._updateReady},o.prototype.canUpdate=function(){return this._updateReady},o.prototype.download=function(t){var e=this;return e.canDownload()?(localStorage.removeItem("manifest"),localStorage.setItem("last_update_files",JSON.stringify(this.newManifest.files)),this.manifest.files=Manifest.files={},e.cache.remove(e._toBeDeleted,!0).then(function(){return i.all(e._toBeCopied.map(function(t){return e.cache._fs.download(a+t,e.cache.localRoot+t)}))}).then(function(){return e.allowServerRootFromManifest&&e.newManifest.serverRoot&&(e.cache.serverRoot=e.newManifest.serverRoot),e.cache.add(e._toBeDownloaded),e.cache.download(t)}).then(function(){return e._toBeDeleted=[],e._toBeDownloaded=[],e._updateReady=!0,e.newManifest},function(t){return t&&t.length&&e.cache.remove(t),t})):i.resolve(null)},o.prototype.update=function(t){return this._updateReady?(localStorage.setItem("manifest",JSON.stringify(this.newManifest)),t!==!1&&location.reload(),!0):!1},o.prototype.clear=function(){return localStorage.removeItem("last_update_files"),localStorage.removeItem("manifest"),this.cache.clear()},o.prototype.reset=function(){return this.clear().then(function(){location.reload()},function(){location.reload()})},t.exports=o},function(t){function e(t,n,o,r){t.getDirectory(n[0],{create:!0},function(t){n.length>1?e(t,n.slice(1),o,r):o(t)},r)}function n(t){return t=t.substr(0,t.lastIndexOf("/")+1),"/"===t[0]&&(t=t.substr(1)),t}function o(t){return t.substr(t.lastIndexOf("/")+1)}function r(t){return t=t||"","/"===t[0]&&(t=t.substr(1)),t&&t.indexOf(".")<0&&"/"!==t[t.length-1]&&(t+="/"),"./"===t&&(t=""),t}var i=[],a=0;t.exports=function(t){function s(t){return new x(function(e){return e(t)})}function u(t){return new x(function(n,o){return C.then(function(r){t?(t=t.split("/").filter(function(t){return t&&t.length>0&&"."!==t[0]}),e(r.root,t,n,o)):n(r.root)},o)})}function c(t,e){return new x(function(n,o){return"object"==typeof t?n(t):(t=r(t),e=e||{},C.then(function(r){r.root.getFile(t,e,n,o)},o))})}function f(t,e){return t=r(t),e=e||{},new x(function(n,o){return C.then(function(r){t&&"/"!==t?r.root.getDirectory(t,e,n,o):n(r.root)},o)})}function l(t,e){e=e||"";var n=e.indexOf("r")>-1,o=e.indexOf("e")>-1,r=e.indexOf("f")>-1,i=e.indexOf("d")>-1;return r&&i&&(r=!1,i=!1),new x(function(e,a){return f(t).then(function(t){var u=t.createReader();u.readEntries(function(t){var u=[s(t)];n&&t.filter(function(t){return t.isDirectory}).forEach(function(t){u.push(l(t.fullPath,"re"))}),x.all(u).then(function(t){var n=[];n=n.concat.apply(n,t),r&&(n=n.filter(function(t){return t.isFile})),i&&(n=n.filter(function(t){return t.isDirectory})),o||(n=n.map(function(t){return t.fullPath})),e(n)},a)},a)},a)})}function d(t){return new x(function(e,n){c(t).then(function(t){e(t)},function(t){1===t.code?e(!1):n(t)})})}function h(t){return u(n(t)).then(function(){return c(t,{create:!0})})}function p(t){return c(t).then(function(t){return t.toURL()})}function w(t,e){return e=e||"readAsText",c(t).then(function(t){return new x(function(n,o){t.file(function(t){var o=new FileReader;o.onloadend=function(){n(this.result)},o[e](t)},o)})})}function v(t){return w(t,"readAsDataURL")}function y(t){return w(t).then(JSON.parse)}function m(t,e,o){return u(n(t)).then(function(){return c(t,{create:!0})}).then(function(t){return new x(function(n,r){t.createWriter(function(t){t.onwriteend=n,t.onerror=r,"string"==typeof e?e=new Blob([e],{type:o||"text/plain"}):e instanceof Blob!=!0&&(e=new Blob([JSON.stringify(e,null,4)],{type:o||"application/json"})),t.write(e)},r)})})}function _(t,e){return u(n(e)).then(function(n){return c(t).then(function(t){return new x(function(r,i){t.moveTo(n,o(e),r,i)})})})}function g(t,e){return u(n(e)).then(function(n){return c(t).then(function(t){return new x(function(r,i){t.copyTo(n,o(e),r,i)})})})}function R(t,e){var n=e?c:d;return new x(function(e,o){n(t).then(function(t){t!==!1?t.remove(e,o):e(1)},o)}).then(function(t){return 1===t?!1:!0})}function b(t){return f(t).then(function(t){return new x(function(e,n){t.removeRecursively(e,n)})})}function S(){for(;i.length>0&&a<t.concurrency;){a++;var e=i.pop(),n=e.shift(),o=e.shift(),r=e.shift(),s=e.shift(),u=e.shift(),c=e.shift(),f=e.shift(),l=e.shift();n._aborted?a--:o?(n.download.call(n,r,s,u,c,f,l),n.onprogress&&n.onprogress(new ProgressEvent)):n.upload.call(n,s,r,u,c,l,f)}}function U(t){return a--,S(),t}function D(e,n,o,r,s){"function"==typeof r&&(s=r,r={}),n=encodeURI(n),O&&(o=E(o)),r=r||{},r.retry&&r.retry.length||(r.retry=t.retry),r.retry=r.retry.concat();var u=new FileTransfer;s=s||r.onprogress,"function"==typeof s&&(u.onprogress=s);var c=new x(function(t,s){var c=function(a){if(0===r.retry.length)s(a);else{i.unshift([u,e,n,o,t,c,r.trustAllHosts||!1,r]);var f=r.retry.shift();f>0?setTimeout(U,f):U()}};r.retry.unshift(0),a++,c()});return c.then(U,U),c.progress=function(t){return u.onprogress=t,c},c.abort=function(){return u._aborted=!0,u.abort(),c},c}function L(t,e,n,o){return D(!0,t,e,n,o)}function M(t,e,n,o){return D(!1,e,t,n,o)}var x=t.Promise||window.Promise;if(!x)throw new Error("No Promise library given in options.Promise");this.options=t=t||{},t.persistent=void 0!==t.persistent?t.persistent:!0,t.storageSize=t.storageSize||20971520,t.concurrency=t.concurrency||3,t.retry=t.retry||[];var B,O="undefined"!=typeof cordova;O?B=new x(function(t,e){document.addEventListener("deviceready",t,!1),setTimeout(function(){e(new Error("deviceready has not fired after 5 seconds."))},5100)}):(B=s(!0),"undefined"!=typeof webkitRequestFileSystem?(window.requestFileSystem=webkitRequestFileSystem,window.FileTransfer=function(){},FileTransfer.prototype.download=function(t,e,n,o){var r=new XMLHttpRequest;return r.open("GET",t),r.responseType="blob",r.onreadystatechange=function(){4==r.readyState&&(200===r.status?m(e,r.response).then(n,o):o(r.status))},r.send(),r},window.ProgressEvent=function(){},window.FileEntry=function(){}):window.requestFileSystem=function(t,e,n,o){o(new Error("requestFileSystem not supported!"))});var C=new x(function(e,n){B.then(function(){var o=t.persistent?1:0;"number"==typeof t.fileSystem&&(o=t.fileSystem),!O&&o>1&&(console.warn('Chrome does not support fileSystem "'+o+'". Falling back on "0" (temporary).'),o=0),window.requestFileSystem(o,t.storageSize,e,n),setTimeout(function(){n(new Error("Could not retrieve FileSystem after 5 seconds."))},5100)},n)});C.then(function(t){window.__fs=t},function(t){console.error("Could not get Cordova FileSystem:",t)});var F,E;return O?(E=function(e){return e=r(e),"cdvfile://localhost/"+(t.persistent?"persistent/":"temporary/")+e},F=function(t){return c(t).then(function(t){return t.toInternalURL()})}):(E=function(e){return e=r(e),"filesystem:"+location.origin+(t.persistent?"/persistent/":"/temporary/")+e},F=function(t){return c(t).then(function(t){return t.toURL()})}),{fs:C,normalize:r,file:c,filename:o,dir:f,dirname:n,create:h,read:w,readJSON:y,write:m,move:_,copy:g,remove:R,removeDir:b,list:l,ensure:u,exists:d,download:L,upload:M,toURL:p,isCordova:O,toInternalURLSync:E,toInternalURL:F,toDataURL:v,deviceready:B,options:t,Promise:x}}},function(t,e,n){function o(t){var e=this;if(this._fs=t.fs,!this._fs)throw new Error('Missing required option "fs". Add an instance of cordova-promise-fs.');i=this._fs.Promise,this._mirrorMode="hash"!==t.mode,this._retry=t.retry||[500,1500,8e3],this._cacheBuster=!!t.cacheBuster,this.localRoot=this._fs.normalize(t.localRoot||"data"),this.serverRoot=this._fs.normalize(t.serverRoot||""),this._downloading=[],this._added=[],this._cached={},this.ready=this._fs.ensure(this.localRoot).then(function(t){return e.localInternalURL=a?t.toInternalURL():t.toURL(),e.localUrl=t.toURL(),e.list()})}var r=n(3),i=null,a="undefined"!=typeof cordova;o.prototype.list=function(){var t=this;return new i(function(e){t._fs.list(t.localRoot,"rfe").then(function(n){t._cached={},n=n.map(function(e){var n=t._fs.normalize(e.fullPath);return t._cached[n]={toInternalURL:a?e.toInternalURL():e.toURL(),toURL:e.toURL()},n}),e(n)},function(){e([])})})},o.prototype.add=function(t){t||(t=[]),"string"==typeof t&&(t=[t]);var e=this;return t.forEach(function(t){t=e.toServerURL(t),-1===e._added.indexOf(t)&&e._added.push(t)}),e.isDirty()},o.prototype.remove=function(t,e){t||(t=[]);var n=[];"string"==typeof t&&(t=[t]);var o=this;return t.forEach(function(t){var e=o._added.indexOf(o.toServerURL(t));e>=0&&o._added.splice(e,1);var r=o.toPath(t);n.push(o._fs.remove(r)),delete o._cached[r]}),e?i.all(n):o.isDirty()},o.prototype.getDownloadQueue=function(){var t=this,e=t._added.filter(function(e){return!t.isCached(e)});return e},o.prototype.getAdded=function(){return this._added},o.prototype.isDirty=function(){return this.getDownloadQueue().length>0},o.prototype.download=function(t){var e=this._fs,n=this;return n.abort(),new i(function(o,r){e.ensure(n.localRoot).then(function(){return n.list()}).then(function(){if(!n.isDirty())return void o(n);var i=n.getDownloadQueue(),a=[],s=n._downloading.length,u=n._downloading.length,c=n._downloading.length+i.length;i.forEach(function(i){var f,l=n.toPath(i);"function"==typeof t&&(f=function(e){e.queueIndex=s,e.queueSize=c,e.url=i,e.path=l,e.percentage=s/c,e.loaded>0&&e.total>0&&s!==c&&(e.percentage+=e.loaded/e.total/c),a.indexOf(i)<0&&(a.push(i),s++),t(e)});var d=function(){u++,u===c&&(n._downloading=[],n.list().then(function(){f&&f(new ProgressEvent),n.isDirty()?r(n.getDownloadQueue()):o(n)},r))},h=i;n._cacheBuster&&(h+="?"+Date.now());var p=e.download(h,l,{retry:n._retry},f);p.then(d,d),n._downloading.push(p)})},r)})},o.prototype.abort=function(){this._downloading.forEach(function(t){t.abort()}),this._downloading=[]},o.prototype.isCached=function(t){return t=this.toPath(t),!!this._cached[t]},o.prototype.clear=function(){var t=this;return this._cached={},this._fs.removeDir(this.localRoot).then(function(){return t._fs.ensure(t.localRoot)})},o.prototype.toInternalURL=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toInternalURL:t},o.prototype.get=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toInternalURL:this.toServerURL(t)},o.prototype.toDataURL=function(t){return this._fs.toDataURL(this.toPath(t))},o.prototype.toURL=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toURL:t},o.prototype.toServerURL=function(t){return t=this._fs.normalize(t),t.indexOf("://")<0?this.serverRoot+t:t},o.prototype.toPath=function(t){return this._mirrorMode?(t=t=this._fs.normalize(t||""),len=this.serverRoot.length,t.substr(0,len)!==this.serverRoot?this.localRoot+t:this.localRoot+t.substr(len)):this.localRoot+r(t)+t.substr(t.lastIndexOf("."))},t.exports=o},function(t){function e(t,e){var n,o,r,i,a,s,u,c;for(n=3&t.length,o=t.length-n,r=e,a=3432918353,s=461845907,c=0;o>c;)u=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,r^=u,r=r<<13|r>>>19,i=5*(65535&r)+((5*(r>>>16)&65535)<<16)&4294967295,r=(65535&i)+27492+(((i>>>16)+58964&65535)<<16);switch(u=0,n){case 3:u^=(255&t.charCodeAt(c+2))<<16;case 2:u^=(255&t.charCodeAt(c+1))<<8;case 1:u^=255&t.charCodeAt(c),u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,r^=u}return r^=t.length,r^=r>>>16,r=2246822507*(65535&r)+((2246822507*(r>>>16)&65535)<<16)&4294967295,r^=r>>>13,r=3266489909*(65535&r)+((3266489909*(r>>>16)&65535)<<16)&4294967295,r^=r>>>16,r>>>0}t.exports=e}]);
var CordovaAppLoader=function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){function o(t){if(!t)throw new Error("CordovaAppLoader has no options!");if(!t.fs)throw new Error('CordovaAppLoader has no "fs" option (cordova-promise-fs)');if(!t.serverRoot)throw new Error('CordovaAppLoader has no "serverRoot" option.');if(!window.pegasus||!window.Manifest)throw new Error("CordovaAppLoader bootstrap.js is missing.");this.allowServerRootFromManifest=t.allowServerRootFromManifest===!0,i=t.fs.Promise,this.manifest=window.Manifest,this.newManifest=null,this.bundledManifest=null,this._lastUpdateFiles=localStorage.getItem("last_update_files"),t.serverRoot=t.serverRoot||"",t.serverRoot&&"/"!==t.serverRoot[t.serverRoot.length-1]&&(t.serverRoot+="/"),this.newManifestUrl=t.manifestUrl||t.serverRoot+(t.manifest||"manifest.json"),t.mode&&(t.mode="mirror"),this.cache=new r(t),this.corruptNewManifest=!1,this._toBeCopied=[],this._toBeDeleted=[],this._toBeDownloaded=[],this._updateReady=!1,this._checkTimeout=t.checkTimeout||1e4}var r=n(1),i=(n(2),null),a=location.href.replace(location.hash,"");a=a.substr(0,a.lastIndexOf("/")+1),/ip(hone|ad|od)/i.test(navigator.userAgent)&&(a=location.pathname.substr(location.pathname.indexOf("/www/")),a=a.substr(0,a.lastIndexOf("/")+1),a="cdvfile://localhost/bundle"+a),o.prototype._createFilemap=function(t){var e={},n=this.cache._fs.normalize;return Object.keys(t).forEach(function(o){t[o].filename=n(t[o].filename),e[t[o].filename]=t[o]}),e},o.prototype.copyFromBundle=function(t){var e=a+t;return this.cache._fs.download(e,this.cache.localRoot+t)},o.prototype.getBundledManifest=function(){var t=this,e=document.querySelector("script[manifest]"),n=(e?e.getAttribute("manifest"):null)||"manifest.json";return new i(function(e,o){t.bundledManifest?e(t.bundledManifest):(pegasus(n).then(function(n){t.bundledManifest=n,e(n)},o),setTimeout(function(){o(new Error("bundled manifest timeout"))},t._checkTimeout))})},o.prototype.check=function(t){var e=this,n=this.manifest;"string"==typeof t&&(e.newManifestUrl=t,t=void 0);var o=new i(function(n,o){"object"==typeof t?n(t):(pegasus(e.newManifestUrl).then(n,o),setTimeout(function(){o(new Error("new manifest timeout"))},e._checkTimeout))});return new i(function(t,r){i.all([o,e.getBundledManifest(),e.cache.list()]).then(function(o){var i=o[0],a=o[1];if(JSON.stringify(i.files)===e._lastUpdateFiles)return JSON.stringify(i.files)!==JSON.stringify(Manifest.files)&&(console.warn("New manifest available, but an earlier update attempt failed. Will not download."),e.corruptNewManifest=!0,t(null)),void t(!1);if(!i.files)return void r('Downloaded Manifest has no "files" attribute.');var s=o[2],u=e._createFilemap(n.files),c=e._createFilemap(i.files),f=e._createFilemap(a.files);e._toBeDownloaded=[],e._toBeCopied=[],e._toBeDeleted=[];var l=e.cache._fs.isCordova;Object.keys(c).filter(function(t){return!u[t]||u[t].version!==c[t].version||!e.cache.isCached(t)}).forEach(function(t){l&&f[t]&&f[t].version===c[t].version?e._toBeCopied.push(t):e._toBeDownloaded.push(t)}),e._toBeDeleted=s.map(function(t){return t.substr(e.cache.localRoot.length)}).filter(function(t){return!c[t]||e._toBeDownloaded.indexOf(t)>=0||e._toBeCopied.indexOf(t)>=0});var d=e._toBeDeleted.length+e._toBeDownloaded.length;d>0?(e.newManifest=i,e.newManifest.root=e.cache.localInternalURL,t(!0)):t(!1)},function(t){r(t)})})},o.prototype.canDownload=function(){return!!this.newManifest&&!this._updateReady},o.prototype.canUpdate=function(){return this._updateReady},o.prototype.download=function(t){var e=this;return e.canDownload()?(localStorage.removeItem("manifest"),localStorage.setItem("last_update_files",JSON.stringify(this.newManifest.files)),this.manifest.files=Manifest.files={},e.cache.remove(e._toBeDeleted,!0).then(function(){return i.all(e._toBeCopied.map(function(t){return e.cache._fs.download(a+t,e.cache.localRoot+t)}))}).then(function(){return e.allowServerRootFromManifest&&e.newManifest.serverRoot&&(e.cache.serverRoot=e.newManifest.serverRoot),e.cache.add(e._toBeDownloaded),e.cache.download(t)}).then(function(){return e._toBeDeleted=[],e._toBeDownloaded=[],e._updateReady=!0,e.newManifest},function(t){return t&&t.length&&e.cache.remove(t),t})):new i(function(t){t(null)})},o.prototype.update=function(t){return this._updateReady?(localStorage.setItem("manifest",JSON.stringify(this.newManifest)),t!==!1&&location.reload(),!0):!1},o.prototype.clear=function(){return localStorage.removeItem("last_update_files"),localStorage.removeItem("manifest"),this.cache.clear()},o.prototype.reset=function(){return this.clear().then(function(){location.reload()},function(){location.reload()})},t.exports=o},function(t,e,n){function o(t){var e=this;if(this._fs=t.fs,!this._fs)throw new Error('Missing required option "fs". Add an instance of cordova-promise-fs.');i=this._fs.Promise,this._mirrorMode="hash"!==t.mode,this._retry=t.retry||[500,1500,8e3],this._cacheBuster=!!t.cacheBuster,this.localRoot=this._fs.normalize(t.localRoot||"data"),this.serverRoot=this._fs.normalize(t.serverRoot||""),this._downloading=[],this._added=[],this._cached={},this.ready=this._fs.ensure(this.localRoot).then(function(t){return e.localInternalURL=a?t.toInternalURL():t.toURL(),e.localUrl=t.toURL(),e.list()})}var r=n(3),i=null,a="undefined"!=typeof cordova;o.prototype.list=function(){var t=this;return new i(function(e){t._fs.list(t.localRoot,"rfe").then(function(n){t._cached={},n=n.map(function(e){var n=t._fs.normalize(e.fullPath);return t._cached[n]={toInternalURL:a?e.toInternalURL():e.toURL(),toURL:e.toURL()},n}),e(n)},function(){e([])})})},o.prototype.add=function(t){t||(t=[]),"string"==typeof t&&(t=[t]);var e=this;return t.forEach(function(t){t=e.toServerURL(t),-1===e._added.indexOf(t)&&e._added.push(t)}),e.isDirty()},o.prototype.remove=function(t,e){t||(t=[]);var n=[];"string"==typeof t&&(t=[t]);var o=this;return t.forEach(function(t){var e=o._added.indexOf(o.toServerURL(t));e>=0&&o._added.splice(e,1);var r=o.toPath(t);n.push(o._fs.remove(r)),delete o._cached[r]}),e?i.all(n):o.isDirty()},o.prototype.getDownloadQueue=function(){var t=this,e=t._added.filter(function(e){return!t.isCached(e)});return e},o.prototype.getAdded=function(){return this._added},o.prototype.isDirty=function(){return this.getDownloadQueue().length>0},o.prototype.download=function(t){var e=this._fs,n=this;return n.abort(),new i(function(o,r){e.ensure(n.localRoot).then(function(){return n.list()}).then(function(){if(!n.isDirty())return void o(n);var i=n.getDownloadQueue(),a=[],s=n._downloading.length,u=n._downloading.length,c=n._downloading.length+i.length;i.forEach(function(i){var f,l=n.toPath(i);"function"==typeof t&&(f=function(e){e.queueIndex=s,e.queueSize=c,e.url=i,e.path=l,e.percentage=s/c,e.loaded>0&&e.total>0&&s!==c&&(e.percentage+=e.loaded/e.total/c),a.indexOf(i)<0&&(a.push(i),s++),t(e)});var d=function(){u++,u===c&&(n._downloading=[],n.list().then(function(){f&&f(new ProgressEvent),n.isDirty()?r(n.getDownloadQueue()):o(n)},r))},h=i;n._cacheBuster&&(h+="?"+Date.now());var p=e.download(h,l,{retry:n._retry},f);p.then(d,d),n._downloading.push(p)})},r)})},o.prototype.abort=function(){this._downloading.forEach(function(t){t.abort()}),this._downloading=[]},o.prototype.isCached=function(t){return t=this.toPath(t),!!this._cached[t]},o.prototype.clear=function(){var t=this;return this._cached={},this._fs.removeDir(this.localRoot).then(function(){return t._fs.ensure(t.localRoot)})},o.prototype.toInternalURL=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toInternalURL:t},o.prototype.get=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toInternalURL:this.toServerURL(t)},o.prototype.toDataURL=function(t){return this._fs.toDataURL(this.toPath(t))},o.prototype.toURL=function(t){return path=this.toPath(t),this._cached[path]?this._cached[path].toURL:t},o.prototype.toServerURL=function(t){return t=this._fs.normalize(t),t.indexOf("://")<0?this.serverRoot+t:t},o.prototype.toPath=function(t){if(this._mirrorMode){var e=t.indexOf("?");return e>-1&&(t=t.substr(0,e)),t=t=this._fs.normalize(t||""),len=this.serverRoot.length,t.substr(0,len)!==this.serverRoot?this.localRoot+t:this.localRoot+t.substr(len)}return this.localRoot+r(t)+t.substr(t.lastIndexOf("."))},t.exports=o},function(t){function e(t,n,o,r){t.getDirectory(n[0],{create:!0},function(t){n.length>1?e(t,n.slice(1),o,r):o(t)},r)}function n(t){return t=t.substr(0,t.lastIndexOf("/")+1),"/"===t[0]&&(t=t.substr(1)),t}function o(t){return t.substr(t.lastIndexOf("/")+1)}function r(t){return t=t||"","/"===t[0]&&(t=t.substr(1)),t&&t.indexOf(".")<0&&"/"!==t[t.length-1]&&(t+="/"),"./"===t&&(t=""),t}var i=[],a=0;t.exports=function(t){function s(t){return new M(function(e){return e(t)})}function u(t){return new M(function(n,o){return C.then(function(r){t?(t=t.split("/").filter(function(t){return t&&t.length>0&&"."!==t&&".."!==t}),e(r.root,t,n,o)):n(r.root)},o)})}function c(t,e){return new M(function(n,o){return"object"==typeof t?n(t):(t=r(t),e=e||{},C.then(function(r){r.root.getFile(t,e,n,o)},o))})}function f(t,e){return t=r(t),e=e||{},new M(function(n,o){return C.then(function(r){t&&"/"!==t?r.root.getDirectory(t,e,n,o):n(r.root)},o)})}function l(t,e){e=e||"";var n=e.indexOf("r")>-1,o=e.indexOf("e")>-1,r=e.indexOf("f")>-1,i=e.indexOf("d")>-1;return r&&i&&(r=!1,i=!1),new M(function(e,a){return f(t).then(function(t){var u=t.createReader();u.readEntries(function(t){var u=[s(t)];n&&t.filter(function(t){return t.isDirectory}).forEach(function(t){u.push(l(t.fullPath,"re"))}),M.all(u).then(function(t){var n=[];n=n.concat.apply(n,t),r&&(n=n.filter(function(t){return t.isFile})),i&&(n=n.filter(function(t){return t.isDirectory})),o||(n=n.map(function(t){return t.fullPath})),e(n)},a)},a)},a)})}function d(t){return new M(function(e,n){c(t).then(function(t){e(t)},function(t){1===t.code?e(!1):n(t)})})}function h(t){return u(n(t)).then(function(){return c(t,{create:!0})})}function p(t){return c(t).then(function(t){return t.toURL()})}function w(t,e){return e=e||"readAsText",c(t).then(function(t){return new M(function(n,o){t.file(function(t){var o=new FileReader;o.onloadend=function(){n(this.result)},o[e](t)},o)})})}function v(t){return w(t,"readAsDataURL")}function y(t){return w(t).then(JSON.parse)}function m(t,e,o){return u(n(t)).then(function(){return c(t,{create:!0})}).then(function(t){return new M(function(n,r){t.createWriter(function(t){t.onwriteend=n,t.onerror=r,"string"==typeof e?e=new Blob([e],{type:o||"text/plain"}):e instanceof Blob!=!0&&(e=new Blob([JSON.stringify(e,null,4)],{type:o||"application/json"})),t.write(e)},r)})})}function _(t,e){return u(n(e)).then(function(n){return c(t).then(function(t){return new M(function(r,i){t.moveTo(n,o(e),r,i)})})})}function g(t,e){return u(n(e)).then(function(n){return c(t).then(function(t){return new M(function(r,i){t.copyTo(n,o(e),r,i)})})})}function R(t,e){var n=e?c:d;return new M(function(e,o){n(t).then(function(t){t!==!1?t.remove(e,o):e(1)},o)}).then(function(t){return 1===t?!1:!0})}function b(t){return f(t).then(function(t){return new M(function(e,n){t.removeRecursively(e,n)})})}function S(){for(;i.length>0&&a<t.concurrency;){a++;var e=i.pop(),n=e.shift(),o=e.shift(),r=e.shift(),s=e.shift(),u=e.shift(),c=e.shift(),f=e.shift(),l=e.shift();n._aborted?a--:o?(n.download.call(n,r,s,u,c,f,l),n.onprogress&&n.onprogress(new ProgressEvent)):n.upload.call(n,s,r,u,c,l,f)}}function U(t){return a--,S(),t}function D(e,n,r,s,u){"function"==typeof s&&(u=s,s={}),B&&r.indexOf("://")<0&&(r=E(r)),s=s||{},s.retry&&s.retry.length||(s.retry=t.retry),s.retry=s.retry.concat(),s.file||e||(s.fileName=o(r));var c=new FileTransfer;u=u||s.onprogress,"function"==typeof u&&(c.onprogress=u);var f=new M(function(t,o){var u=function(a){if(0===s.retry.length)o(a);else{i.unshift([c,e,n,r,t,u,s.trustAllHosts||!1,s]);var f=s.retry.shift();f>0?setTimeout(U,f):U()}};s.retry.unshift(0),a++,u()});return f.then(U,U),f.progress=function(t){return c.onprogress=t,f},f.abort=function(){return c._aborted=!0,c.abort(),f},f}function L(t,e,n,o){return D(!0,t,e,n,o)}function x(t,e,n,o){return D(!1,e,t,n,o)}var M=t.Promise||window.Promise;if("undefined"==typeof M)throw new Error("No Promise library given in options.Promise");this.options=t=t||{},t.persistent=void 0!==t.persistent?t.persistent:!0,t.storageSize=t.storageSize||20971520,t.concurrency=t.concurrency||3,t.retry=t.retry||[];var O,B="undefined"!=typeof cordova;B?O=new M(function(t,e){document.addEventListener("deviceready",t,!1),setTimeout(function(){e(new Error("deviceready has not fired after 5 seconds."))},5100)}):(O=s(!0),"undefined"!=typeof webkitRequestFileSystem?(window.requestFileSystem=webkitRequestFileSystem,window.FileTransfer=function(){},FileTransfer.prototype.download=function(t,e,n,o){var r=new XMLHttpRequest;return r.open("GET",t),r.responseType="blob",r.onreadystatechange=function(){4==r.readyState&&(200===r.status?m(e,r.response).then(n,o):o(r.status))},r.send(),r},window.ProgressEvent=function(){},window.FileEntry=function(){}):window.requestFileSystem=function(t,e,n,o){o(new Error("requestFileSystem not supported!"))});var C=new M(function(e,n){O.then(function(){var o=t.persistent?1:0;"number"==typeof t.fileSystem&&(o=t.fileSystem),!B&&o>1&&(console.warn('Chrome does not support fileSystem "'+o+'". Falling back on "0" (temporary).'),o=0),window.requestFileSystem(o,t.storageSize,e,n),setTimeout(function(){n(new Error("Could not retrieve FileSystem after 5 seconds."))},5100)},n)});C.then(function(t){window.__fs=t},function(t){console.error("Could not get Cordova FileSystem:",t)});var F,E;return B?(E=function(e){return e=r(e),e.indexOf("://")<0?"cdvfile://localhost/"+(t.persistent?"persistent/":"temporary/")+e:e},F=function(t){return c(t).then(function(t){return t.toInternalURL()})}):(E=function(e){return e=r(e),"filesystem:"+location.origin+(t.persistent?"/persistent/":"/temporary/")+e},F=function(t){return c(t).then(function(t){return t.toURL()})}),{fs:C,normalize:r,file:c,filename:o,dir:f,dirname:n,create:h,read:w,readJSON:y,write:m,move:_,copy:g,remove:R,removeDir:b,list:l,ensure:u,exists:d,download:L,upload:x,toURL:p,isCordova:B,toInternalURLSync:E,toInternalURL:F,toDataURL:v,deviceready:O,options:t,Promise:M}}},function(t){function e(t,e){var n,o,r,i,a,s,u,c;for(n=3&t.length,o=t.length-n,r=e,a=3432918353,s=461845907,c=0;o>c;)u=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,r^=u,r=r<<13|r>>>19,i=5*(65535&r)+((5*(r>>>16)&65535)<<16)&4294967295,r=(65535&i)+27492+(((i>>>16)+58964&65535)<<16);switch(u=0,n){case 3:u^=(255&t.charCodeAt(c+2))<<16;case 2:u^=(255&t.charCodeAt(c+1))<<8;case 1:u^=255&t.charCodeAt(c),u=(65535&u)*a+(((u>>>16)*a&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(65535&u)*s+(((u>>>16)*s&65535)<<16)&4294967295,r^=u}return r^=t.length,r^=r>>>16,r=2246822507*(65535&r)+((2246822507*(r>>>16)&65535)<<16)&4294967295,r^=r>>>13,r=3266489909*(65535&r)+((3266489909*(r>>>16)&65535)<<16)&4294967295,r^=r>>>16,r>>>0}t.exports=e}]);

@@ -5,10 +5,10 @@ var CordovaPromiseFS =

/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -20,23 +20,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports

@@ -93,3 +93,3 @@ /******/ return __webpack_require__(0);

var Promise = options.Promise || window.Promise;
if(!Promise) { throw new Error("No Promise library given in options.Promise"); }
if(typeof Promise === 'undefined') { throw new Error("No Promise library given in options.Promise"); }

@@ -180,3 +180,3 @@ /* default options */

folders = folders.split('/').filter(function(folder) {
return folder && folder.length > 0 && folder[0] !== '.';
return folder && folder.length > 0 && folder !== '.' && folder !== '..';
});

@@ -292,3 +292,3 @@ __createDir(fs.root,folders,resolve,reject);

path = normalize(path);
return 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path;
return path.indexOf('://') < 0? 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path: path;
};

@@ -453,4 +453,3 @@

}
serverUrl = encodeURI(serverUrl);
if(isCordova) localPath = toInternalURLSync(localPath);
if(isCordova && localPath.indexOf('://') < 0) localPath = toInternalURLSync(localPath);

@@ -462,2 +461,5 @@ transferOptions = transferOptions || {};

transferOptions.retry = transferOptions.retry.concat();
if(!transferOptions.file && !isDownload){
transferOptions.fileName = filename(localPath);
}

@@ -537,3 +539,4 @@ var ft = new FileTransfer();

/***/ }
/******/ ])
/******/ ]);

@@ -1,1 +0,1 @@

var CordovaPromiseFS=function(n){function e(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var t={};return e.m=n,e.c=t,e.p="",e(0)}([function(n){function e(n,t,r,o){n.getDirectory(t[0],{create:!0},function(n){t.length>1?e(n,t.slice(1),r,o):r(n)},o)}function t(n){return n=n.substr(0,n.lastIndexOf("/")+1),"/"===n[0]&&(n=n.substr(1)),n}function r(n){return n.substr(n.lastIndexOf("/")+1)}function o(n){return n=n||"","/"===n[0]&&(n=n.substr(1)),n&&n.indexOf(".")<0&&"/"!==n[n.length-1]&&(n+="/"),"./"===n&&(n=""),n}var i=[],u=0;n.exports=function(n){function f(n){return new O(function(e){return e(n)})}function c(n){return new O(function(t,r){return q.then(function(o){n?(n=n.split("/").filter(function(n){return n&&n.length>0&&"."!==n[0]}),e(o.root,n,t,r)):t(o.root)},r)})}function s(n,e){return new O(function(t,r){return"object"==typeof n?t(n):(n=o(n),e=e||{},q.then(function(o){o.root.getFile(n,e,t,r)},r))})}function a(n,e){return n=o(n),e=e||{},new O(function(t,r){return q.then(function(o){n&&"/"!==n?o.root.getDirectory(n,e,t,r):t(o.root)},r)})}function l(n,e){e=e||"";var t=e.indexOf("r")>-1,r=e.indexOf("e")>-1,o=e.indexOf("f")>-1,i=e.indexOf("d")>-1;return o&&i&&(o=!1,i=!1),new O(function(e,u){return a(n).then(function(n){var c=n.createReader();c.readEntries(function(n){var c=[f(n)];t&&n.filter(function(n){return n.isDirectory}).forEach(function(n){c.push(l(n.fullPath,"re"))}),O.all(c).then(function(n){var t=[];t=t.concat.apply(t,n),o&&(t=t.filter(function(n){return n.isFile})),i&&(t=t.filter(function(n){return n.isDirectory})),r||(t=t.map(function(n){return n.fullPath})),e(t)},u)},u)},u)})}function d(n){return new O(function(e,t){s(n).then(function(n){e(n)},function(n){1===n.code?e(!1):t(n)})})}function p(n){return c(t(n)).then(function(){return s(n,{create:!0})})}function y(n){return s(n).then(function(n){return n.toURL()})}function h(n,e){return e=e||"readAsText",s(n).then(function(n){return new O(function(t,r){n.file(function(n){var r=new FileReader;r.onloadend=function(){t(this.result)},r[e](n)},r)})})}function w(n){return h(n,"readAsDataURL")}function v(n){return h(n).then(JSON.parse)}function m(n,e,r){return c(t(n)).then(function(){return s(n,{create:!0})}).then(function(n){return new O(function(t,o){n.createWriter(function(n){n.onwriteend=t,n.onerror=o,"string"==typeof e?e=new Blob([e],{type:r||"text/plain"}):e instanceof Blob!=!0&&(e=new Blob([JSON.stringify(e,null,4)],{type:r||"application/json"})),n.write(e)},o)})})}function g(n,e){return c(t(e)).then(function(t){return s(n).then(function(n){return new O(function(o,i){n.moveTo(t,r(e),o,i)})})})}function S(n,e){return c(t(e)).then(function(t){return s(n).then(function(n){return new O(function(o,i){n.copyTo(t,r(e),o,i)})})})}function b(n,e){var t=e?s:d;return new O(function(e,r){t(n).then(function(n){n!==!1?n.remove(e,r):e(1)},r)}).then(function(n){return 1===n?!1:!0})}function F(n){return a(n).then(function(n){return new O(function(e,t){n.removeRecursively(e,t)})})}function x(){for(;i.length>0&&u<n.concurrency;){u++;var e=i.pop(),t=e.shift(),r=e.shift(),o=e.shift(),f=e.shift(),c=e.shift(),s=e.shift(),a=e.shift(),l=e.shift();t._aborted?u--:r?(t.download.call(t,o,f,c,s,a,l),t.onprogress&&t.onprogress(new ProgressEvent)):t.upload.call(t,f,o,c,s,l,a)}}function R(n){return u--,x(),n}function E(e,t,r,o,f){"function"==typeof o&&(f=o,o={}),t=encodeURI(t),U&&(r=C(r)),o=o||{},o.retry&&o.retry.length||(o.retry=n.retry),o.retry=o.retry.concat();var c=new FileTransfer;f=f||o.onprogress,"function"==typeof f&&(c.onprogress=f);var s=new O(function(n,f){var s=function(u){if(0===o.retry.length)f(u);else{i.unshift([c,e,t,r,n,s,o.trustAllHosts||!1,o]);var a=o.retry.shift();a>0?setTimeout(R,a):R()}};o.retry.unshift(0),u++,s()});return s.then(R,R),s.progress=function(n){return c.onprogress=n,s},s.abort=function(){return c._aborted=!0,c.abort(),s},s}function T(n,e,t,r){return E(!0,n,e,t,r)}function L(n,e,t,r){return E(!1,e,n,t,r)}var O=n.Promise||window.Promise;if(!O)throw new Error("No Promise library given in options.Promise");this.options=n=n||{},n.persistent=void 0!==n.persistent?n.persistent:!0,n.storageSize=n.storageSize||20971520,n.concurrency=n.concurrency||3,n.retry=n.retry||[];var P,U="undefined"!=typeof cordova;U?P=new O(function(n,e){document.addEventListener("deviceready",n,!1),setTimeout(function(){e(new Error("deviceready has not fired after 5 seconds."))},5100)}):(P=f(!0),"undefined"!=typeof webkitRequestFileSystem?(window.requestFileSystem=webkitRequestFileSystem,window.FileTransfer=function(){},FileTransfer.prototype.download=function(n,e,t,r){var o=new XMLHttpRequest;return o.open("GET",n),o.responseType="blob",o.onreadystatechange=function(){4==o.readyState&&(200===o.status?m(e,o.response).then(t,r):r(o.status))},o.send(),o},window.ProgressEvent=function(){},window.FileEntry=function(){}):window.requestFileSystem=function(n,e,t,r){r(new Error("requestFileSystem not supported!"))});var q=new O(function(e,t){P.then(function(){var r=n.persistent?1:0;"number"==typeof n.fileSystem&&(r=n.fileSystem),!U&&r>1&&(console.warn('Chrome does not support fileSystem "'+r+'". Falling back on "0" (temporary).'),r=0),window.requestFileSystem(r,n.storageSize,e,t),setTimeout(function(){t(new Error("Could not retrieve FileSystem after 5 seconds."))},5100)},t)});q.then(function(n){window.__fs=n},function(n){console.error("Could not get Cordova FileSystem:",n)});var D,C;return U?(C=function(e){return e=o(e),"cdvfile://localhost/"+(n.persistent?"persistent/":"temporary/")+e},D=function(n){return s(n).then(function(n){return n.toInternalURL()})}):(C=function(e){return e=o(e),"filesystem:"+location.origin+(n.persistent?"/persistent/":"/temporary/")+e},D=function(n){return s(n).then(function(n){return n.toURL()})}),{fs:q,normalize:o,file:s,filename:r,dir:a,dirname:t,create:p,read:h,readJSON:v,write:m,move:g,copy:S,remove:b,removeDir:F,list:l,ensure:c,exists:d,download:T,upload:L,toURL:y,isCordova:U,toInternalURLSync:C,toInternalURL:D,toDataURL:w,deviceready:P,options:n,Promise:O}}}]);
var CordovaPromiseFS=function(n){function e(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return n[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var t={};return e.m=n,e.c=t,e.p="",e(0)}([function(n){function e(n,t,r,o){n.getDirectory(t[0],{create:!0},function(n){t.length>1?e(n,t.slice(1),r,o):r(n)},o)}function t(n){return n=n.substr(0,n.lastIndexOf("/")+1),"/"===n[0]&&(n=n.substr(1)),n}function r(n){return n.substr(n.lastIndexOf("/")+1)}function o(n){return n=n||"","/"===n[0]&&(n=n.substr(1)),n&&n.indexOf(".")<0&&"/"!==n[n.length-1]&&(n+="/"),"./"===n&&(n=""),n}var i=[],u=0;n.exports=function(n){function f(n){return new L(function(e){return e(n)})}function s(n){return new L(function(t,r){return q.then(function(o){n?(n=n.split("/").filter(function(n){return n&&n.length>0&&"."!==n&&".."!==n}),e(o.root,n,t,r)):t(o.root)},r)})}function c(n,e){return new L(function(t,r){return"object"==typeof n?t(n):(n=o(n),e=e||{},q.then(function(o){o.root.getFile(n,e,t,r)},r))})}function a(n,e){return n=o(n),e=e||{},new L(function(t,r){return q.then(function(o){n&&"/"!==n?o.root.getDirectory(n,e,t,r):t(o.root)},r)})}function l(n,e){e=e||"";var t=e.indexOf("r")>-1,r=e.indexOf("e")>-1,o=e.indexOf("f")>-1,i=e.indexOf("d")>-1;return o&&i&&(o=!1,i=!1),new L(function(e,u){return a(n).then(function(n){var s=n.createReader();s.readEntries(function(n){var s=[f(n)];t&&n.filter(function(n){return n.isDirectory}).forEach(function(n){s.push(l(n.fullPath,"re"))}),L.all(s).then(function(n){var t=[];t=t.concat.apply(t,n),o&&(t=t.filter(function(n){return n.isFile})),i&&(t=t.filter(function(n){return n.isDirectory})),r||(t=t.map(function(n){return n.fullPath})),e(t)},u)},u)},u)})}function d(n){return new L(function(e,t){c(n).then(function(n){e(n)},function(n){1===n.code?e(!1):t(n)})})}function p(n){return s(t(n)).then(function(){return c(n,{create:!0})})}function y(n){return c(n).then(function(n){return n.toURL()})}function h(n,e){return e=e||"readAsText",c(n).then(function(n){return new L(function(t,r){n.file(function(n){var r=new FileReader;r.onloadend=function(){t(this.result)},r[e](n)},r)})})}function w(n){return h(n,"readAsDataURL")}function v(n){return h(n).then(JSON.parse)}function m(n,e,r){return s(t(n)).then(function(){return c(n,{create:!0})}).then(function(n){return new L(function(t,o){n.createWriter(function(n){n.onwriteend=t,n.onerror=o,"string"==typeof e?e=new Blob([e],{type:r||"text/plain"}):e instanceof Blob!=!0&&(e=new Blob([JSON.stringify(e,null,4)],{type:r||"application/json"})),n.write(e)},o)})})}function g(n,e){return s(t(e)).then(function(t){return c(n).then(function(n){return new L(function(o,i){n.moveTo(t,r(e),o,i)})})})}function S(n,e){return s(t(e)).then(function(t){return c(n).then(function(n){return new L(function(o,i){n.copyTo(t,r(e),o,i)})})})}function b(n,e){var t=e?c:d;return new L(function(e,r){t(n).then(function(n){n!==!1?n.remove(e,r):e(1)},r)}).then(function(n){return 1===n?!1:!0})}function x(n){return a(n).then(function(n){return new L(function(e,t){n.removeRecursively(e,t)})})}function F(){for(;i.length>0&&u<n.concurrency;){u++;var e=i.pop(),t=e.shift(),r=e.shift(),o=e.shift(),f=e.shift(),s=e.shift(),c=e.shift(),a=e.shift(),l=e.shift();t._aborted?u--:r?(t.download.call(t,o,f,s,c,a,l),t.onprogress&&t.onprogress(new ProgressEvent)):t.upload.call(t,f,o,s,c,l,a)}}function R(n){return u--,F(),n}function O(e,t,o,f,s){"function"==typeof f&&(s=f,f={}),U&&o.indexOf("://")<0&&(o=C(o)),f=f||{},f.retry&&f.retry.length||(f.retry=n.retry),f.retry=f.retry.concat(),f.file||e||(f.fileName=r(o));var c=new FileTransfer;s=s||f.onprogress,"function"==typeof s&&(c.onprogress=s);var a=new L(function(n,r){var s=function(u){if(0===f.retry.length)r(u);else{i.unshift([c,e,t,o,n,s,f.trustAllHosts||!1,f]);var a=f.retry.shift();a>0?setTimeout(R,a):R()}};f.retry.unshift(0),u++,s()});return a.then(R,R),a.progress=function(n){return c.onprogress=n,a},a.abort=function(){return c._aborted=!0,c.abort(),a},a}function E(n,e,t,r){return O(!0,n,e,t,r)}function T(n,e,t,r){return O(!1,e,n,t,r)}var L=n.Promise||window.Promise;if("undefined"==typeof L)throw new Error("No Promise library given in options.Promise");this.options=n=n||{},n.persistent=void 0!==n.persistent?n.persistent:!0,n.storageSize=n.storageSize||20971520,n.concurrency=n.concurrency||3,n.retry=n.retry||[];var P,U="undefined"!=typeof cordova;U?P=new L(function(n,e){document.addEventListener("deviceready",n,!1),setTimeout(function(){e(new Error("deviceready has not fired after 5 seconds."))},5100)}):(P=f(!0),"undefined"!=typeof webkitRequestFileSystem?(window.requestFileSystem=webkitRequestFileSystem,window.FileTransfer=function(){},FileTransfer.prototype.download=function(n,e,t,r){var o=new XMLHttpRequest;return o.open("GET",n),o.responseType="blob",o.onreadystatechange=function(){4==o.readyState&&(200===o.status?m(e,o.response).then(t,r):r(o.status))},o.send(),o},window.ProgressEvent=function(){},window.FileEntry=function(){}):window.requestFileSystem=function(n,e,t,r){r(new Error("requestFileSystem not supported!"))});var q=new L(function(e,t){P.then(function(){var r=n.persistent?1:0;"number"==typeof n.fileSystem&&(r=n.fileSystem),!U&&r>1&&(console.warn('Chrome does not support fileSystem "'+r+'". Falling back on "0" (temporary).'),r=0),window.requestFileSystem(r,n.storageSize,e,t),setTimeout(function(){t(new Error("Could not retrieve FileSystem after 5 seconds."))},5100)},t)});q.then(function(n){window.__fs=n},function(n){console.error("Could not get Cordova FileSystem:",n)});var D,C;return U?(C=function(e){return e=o(e),e.indexOf("://")<0?"cdvfile://localhost/"+(n.persistent?"persistent/":"temporary/")+e:e},D=function(n){return c(n).then(function(n){return n.toInternalURL()})}):(C=function(e){return e=o(e),"filesystem:"+location.origin+(n.persistent?"/persistent/":"/temporary/")+e},D=function(n){return c(n).then(function(n){return n.toURL()})}),{fs:q,normalize:o,file:c,filename:r,dir:a,dirname:t,create:p,read:h,readJSON:v,write:m,move:g,copy:S,remove:b,removeDir:x,list:l,ensure:s,exists:d,download:E,upload:T,toURL:y,isCordova:U,toInternalURLSync:C,toInternalURL:D,toDataURL:w,deviceready:P,options:n,Promise:L}}}]);

@@ -177,2 +177,4 @@ var CordovaFileCache = require('cordova-file-cache');

}
}, function(err){
reject(err);
}); // end of .then

@@ -193,3 +195,3 @@ }); // end of new Promise

if(!self.canDownload()) {
return Promise.resolve(null);
return new Promise(function(resolve){ resolve(null); });
}

@@ -196,0 +198,0 @@ // we will delete files, which will invalidate the current manifest...

{
"name": "cordova-app-loader",
"version": "0.14.0",
"version": "0.15.0",
"description": "Cordova App Loader - remote update your cordova app",

@@ -28,4 +28,4 @@ "main": "index.js",

"dependencies": {
"cordova-file-cache": "^0.10.0"
"cordova-file-cache": "^0.11.0"
}
}

@@ -407,2 +407,9 @@ cordova-app-loader

### 0.15.0 (17/03/2013)
* Fix: Missing reject (issue #26) -- thanks very much @pheinicke!
* Fix: Promise.resolve is not in A+ spec. (issue #23).
* Updated cordova-file-cache dependency.
* Fix: Improved Cordova detection (wait for deviceready) in **bootstrap.js** (issue #17)
### 0.14.0 (22/1/2014)

@@ -409,0 +416,0 @@

@@ -93,3 +93,3 @@ (function(){

// If we're loading Cordova files, make sure Cordova is ready first!
if(manifest.root.substr(0,7) === 'cdvfile'){
if(typeof window.cordova !== 'undefined'){
document.addEventListener("deviceready", loadScripts, false);

@@ -96,0 +96,0 @@ } else {

/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -18,23 +18,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports

@@ -234,2 +234,4 @@ /******/ return __webpack_require__(0);

}
}, function(err){
reject(err);
}); // end of .then

@@ -250,3 +252,3 @@ }); // end of new Promise

if(!self.canDownload()) {
return Promise.resolve(null);
return new Promise(function(resolve){ resolve(null); });
}

@@ -554,2 +556,6 @@ // we will delete files, which will invalidate the current manifest...

if(this._mirrorMode) {
var query = url.indexOf('?');
if(query > -1){
url = url.substr(0,query);
}
url = url = this._fs.normalize(url || '');

@@ -616,3 +622,3 @@ len = this.serverRoot.length;

var Promise = options.Promise || window.Promise;
if(!Promise) { throw new Error("No Promise library given in options.Promise"); }
if(typeof Promise === 'undefined') { throw new Error("No Promise library given in options.Promise"); }

@@ -703,3 +709,3 @@ /* default options */

folders = folders.split('/').filter(function(folder) {
return folder && folder.length > 0 && folder[0] !== '.';
return folder && folder.length > 0 && folder !== '.' && folder !== '..';
});

@@ -815,3 +821,3 @@ __createDir(fs.root,folders,resolve,reject);

path = normalize(path);
return 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path;
return path.indexOf('://') < 0? 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path: path;
};

@@ -976,4 +982,3 @@

}
serverUrl = encodeURI(serverUrl);
if(isCordova) localPath = toInternalURLSync(localPath);
if(isCordova && localPath.indexOf('://') < 0) localPath = toInternalURLSync(localPath);

@@ -985,2 +990,5 @@ transferOptions = transferOptions || {};

transferOptions.retry = transferOptions.retry.concat();
if(!transferOptions.file && !isDownload){
transferOptions.fileName = filename(localPath);
}

@@ -1060,2 +1068,3 @@ var ft = new FileTransfer();

/***/ },

@@ -1065,3 +1074,3 @@ /* 4 */

/**@license MIT-promiscuous-©Ruben Verborgh*/
/* WEBPACK VAR INJECTION */(function(setImmediate) {/**@license MIT-promiscuous-©Ruben Verborgh*/
(function (func, obj) {

@@ -1194,2 +1203,3 @@ // Type checking utility function

/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6).setImmediate))

@@ -1267,3 +1277,149 @@ /***/ },

/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(7).nextTick;
var apply = Function.prototype.apply;
var slice = Array.prototype.slice;
var immediateIds = {};
var nextImmediateId = 0;
// DOM APIs, for completeness
exports.setTimeout = function() {
return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
};
exports.setInterval = function() {
return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
};
exports.clearTimeout =
exports.clearInterval = function(timeout) { timeout.close(); };
function Timeout(id, clearFn) {
this._id = id;
this._clearFn = clearFn;
}
Timeout.prototype.unref = Timeout.prototype.ref = function() {};
Timeout.prototype.close = function() {
this._clearFn.call(window, this._id);
};
// Does not start the time, just sets up the members needed.
exports.enroll = function(item, msecs) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = msecs;
};
exports.unenroll = function(item) {
clearTimeout(item._idleTimeoutId);
item._idleTimeout = -1;
};
exports._unrefActive = exports.active = function(item) {
clearTimeout(item._idleTimeoutId);
var msecs = item._idleTimeout;
if (msecs >= 0) {
item._idleTimeoutId = setTimeout(function onTimeout() {
if (item._onTimeout)
item._onTimeout();
}, msecs);
}
};
// That's not how node.js implements it but the exposed api is the same.
exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
var id = nextImmediateId++;
var args = arguments.length < 2 ? false : slice.call(arguments, 1);
immediateIds[id] = true;
nextTick(function onNextTick() {
if (immediateIds[id]) {
// fn.call() is faster so we optimize for the common use-case
// @see http://jsperf.com/call-apply-segu
if (args) {
fn.apply(null, args);
} else {
fn.call(null);
}
// Prevent ids from leaking
exports.clearImmediate(id);
}
});
return id;
};
exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
delete immediateIds[id];
};
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6).setImmediate, __webpack_require__(6).clearImmediate))
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
// shim for using process in browser
var process = module.exports = {};
var queue = [];
var draining = false;
function drainQueue() {
if (draining) {
return;
}
draining = true;
var currentQueue;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
var i = -1;
while (++i < len) {
currentQueue[i]();
}
len = queue.length;
}
draining = false;
}
process.nextTick = function (fun) {
queue.push(fun);
if (!draining) {
setTimeout(drainQueue, 0);
}
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
// TODO(shtylman)
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }
/******/ ])
/******/ ]);

@@ -5,10 +5,10 @@ var CordovaAppLoader =

/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -20,23 +20,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports

@@ -50,4 +50,4 @@ /******/ return __webpack_require__(0);

var CordovaFileCache = __webpack_require__(2);
var CordovaPromiseFS = __webpack_require__(1);
var CordovaFileCache = __webpack_require__(1);
var CordovaPromiseFS = __webpack_require__(2);
var Promise = null;

@@ -227,2 +227,4 @@

}
}, function(err){
reject(err);
}); // end of .then

@@ -243,3 +245,3 @@ }); // end of new Promise

if(!self.canDownload()) {
return Promise.resolve(null);
return new Promise(function(resolve){ resolve(null); });
}

@@ -307,3 +309,265 @@ // we will delete files, which will invalidate the current manifest...

var hash = __webpack_require__(3);
var Promise = null;
var isCordova = typeof cordova !== 'undefined';
/* Cordova File Cache x */
function FileCache(options){
var self = this;
// cordova-promise-fs
this._fs = options.fs;
if(!this._fs) {
throw new Error('Missing required option "fs". Add an instance of cordova-promise-fs.');
}
// Use Promises from fs.
Promise = this._fs.Promise;
// 'mirror' mirrors files structure from "serverRoot" to "localRoot"
// 'hash' creates a 1-deep filestructure, where the filenames are hashed server urls (with extension)
this._mirrorMode = options.mode !== 'hash';
this._retry = options.retry || [500,1500,8000];
this._cacheBuster = !!options.cacheBuster;
// normalize path
this.localRoot = this._fs.normalize(options.localRoot || 'data');
this.serverRoot = this._fs.normalize(options.serverRoot || '');
// set internal variables
this._downloading = []; // download promises
this._added = []; // added files
this._cached = {}; // cached files
// list existing cache contents
this.ready = this._fs.ensure(this.localRoot)
.then(function(entry){
self.localInternalURL = isCordova? entry.toInternalURL(): entry.toURL();
self.localUrl = entry.toURL();
return self.list();
});
}
/**
* Helper to cache all 'internalURL' and 'URL' for quick synchronous access
* to the cached files.
*/
FileCache.prototype.list = function list(){
var self = this;
return new Promise(function(resolve,reject){
self._fs.list(self.localRoot,'rfe').then(function(entries){
self._cached = {};
entries = entries.map(function(entry){
var fullPath = self._fs.normalize(entry.fullPath);
self._cached[fullPath] = {
toInternalURL: isCordova? entry.toInternalURL(): entry.toURL(),
toURL: entry.toURL(),
};
return fullPath;
});
resolve(entries);
},function(){
resolve([]);
});
});
};
FileCache.prototype.add = function add(urls){
if(!urls) urls = [];
if(typeof urls === 'string') urls = [urls];
var self = this;
urls.forEach(function(url){
url = self.toServerURL(url);
if(self._added.indexOf(url) === -1) {
self._added.push(url);
}
});
return self.isDirty();
};
FileCache.prototype.remove = function remove(urls,returnPromises){
if(!urls) urls = [];
var promises = [];
if(typeof urls === 'string') urls = [urls];
var self = this;
urls.forEach(function(url){
var index = self._added.indexOf(self.toServerURL(url));
if(index >= 0) self._added.splice(index,1);
var path = self.toPath(url);
promises.push(self._fs.remove(path));
delete self._cached[path];
});
return returnPromises? Promise.all(promises): self.isDirty();
};
FileCache.prototype.getDownloadQueue = function(){
var self = this;
var queue = self._added.filter(function(url){
return !self.isCached(url);
});
return queue;
};
FileCache.prototype.getAdded = function() {
return this._added;
};
FileCache.prototype.isDirty = function isDirty(){
return this.getDownloadQueue().length > 0;
};
FileCache.prototype.download = function download(onprogress){
var fs = this._fs;
var self = this;
self.abort();
return new Promise(function(resolve,reject){
// make sure cache directory exists and that
// we have retrieved the latest cache contents
// to avoid downloading files we already have!
fs.ensure(self.localRoot).then(function(){
return self.list();
}).then(function(){
// no dowloads needed, resolve
if(!self.isDirty()) {
resolve(self);
return;
}
// keep track of number of downloads!
var queue = self.getDownloadQueue();
var started = [];
var index = self._downloading.length;
var done = self._downloading.length;
var total = self._downloading.length + queue.length;
// download every file in the queue (which is the diff from _added with _cached)
queue.forEach(function(url){
var path = self.toPath(url);
// augment progress event with index/total stats
var onSingleDownloadProgress;
if(typeof onprogress === 'function') {
onSingleDownloadProgress = function(ev){
ev.queueIndex = index;
ev.queueSize = total;
ev.url = url;
ev.path = path;
ev.percentage = index / total;
if(ev.loaded > 0 && ev.total > 0 && index !== total){
ev.percentage += (ev.loaded / ev.total) / total;
}
if(started.indexOf(url) < 0) {
started.push(url);
index++;
}
onprogress(ev);
};
}
// callback
var onDone = function(){
done++;
// when we're done
if(done === total) {
// reset downloads
self._downloading = [];
// check if we got everything
self.list().then(function(){
// final progress event!
if(onSingleDownloadProgress) onSingleDownloadProgress(new ProgressEvent());
// Yes, we're not dirty anymore!
if(!self.isDirty()) {
resolve(self);
// Aye, some files got left behind!
} else {
reject(self.getDownloadQueue());
}
},reject);
}
};
var downloadUrl = url;
if(self._cacheBuster) downloadUrl += "?"+Date.now();
var download = fs.download(downloadUrl,path,{retry:self._retry},onSingleDownloadProgress);
download.then(onDone,onDone);
self._downloading.push(download);
});
},reject);
});
};
FileCache.prototype.abort = function abort(){
this._downloading.forEach(function(download){
download.abort();
});
this._downloading = [];
};
FileCache.prototype.isCached = function isCached(url){
url = this.toPath(url);
return !!this._cached[url];
};
FileCache.prototype.clear = function clear(){
var self = this;
this._cached = {};
return this._fs.removeDir(this.localRoot).then(function(){
return self._fs.ensure(self.localRoot);
});
};
/**
* Helpers to output to various formats
*/
FileCache.prototype.toInternalURL = function toInternalURL(url){
path = this.toPath(url);
if(this._cached[path]) return this._cached[path].toInternalURL;
return url;
};
FileCache.prototype.get = function get(url){
path = this.toPath(url);
if(this._cached[path]) return this._cached[path].toInternalURL;
return this.toServerURL(url);
};
FileCache.prototype.toDataURL = function toDataURL(url){
return this._fs.toDataURL(this.toPath(url));
};
FileCache.prototype.toURL = function toURL(url){
path = this.toPath(url);
return this._cached[path]? this._cached[path].toURL: url;
};
FileCache.prototype.toServerURL = function toServerURL(path){
path = this._fs.normalize(path);
return path.indexOf('://') < 0? this.serverRoot + path: path;
};
/**
* Helper to transform remote URL to a local path (for cordova-promise-fs)
*/
FileCache.prototype.toPath = function toPath(url){
if(this._mirrorMode) {
var query = url.indexOf('?');
if(query > -1){
url = url.substr(0,query);
}
url = url = this._fs.normalize(url || '');
len = this.serverRoot.length;
if(url.substr(0,len) !== this.serverRoot) {
return this.localRoot + url;
} else {
return this.localRoot + url.substr(len);
}
} else {
return this.localRoot + hash(url) + url.substr(url.lastIndexOf('.'));
}
};
module.exports = FileCache;
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
/**
* Static Private functions

@@ -351,3 +615,3 @@ */

var Promise = options.Promise || window.Promise;
if(!Promise) { throw new Error("No Promise library given in options.Promise"); }
if(typeof Promise === 'undefined') { throw new Error("No Promise library given in options.Promise"); }

@@ -438,3 +702,3 @@ /* default options */

folders = folders.split('/').filter(function(folder) {
return folder && folder.length > 0 && folder[0] !== '.';
return folder && folder.length > 0 && folder !== '.' && folder !== '..';
});

@@ -550,3 +814,3 @@ __createDir(fs.root,folders,resolve,reject);

path = normalize(path);
return 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path;
return path.indexOf('://') < 0? 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path: path;
};

@@ -711,4 +975,3 @@

}
serverUrl = encodeURI(serverUrl);
if(isCordova) localPath = toInternalURLSync(localPath);
if(isCordova && localPath.indexOf('://') < 0) localPath = toInternalURLSync(localPath);

@@ -720,2 +983,5 @@ transferOptions = transferOptions || {};

transferOptions.retry = transferOptions.retry.concat();
if(!transferOptions.file && !isDownload){
transferOptions.fileName = filename(localPath);
}

@@ -795,260 +1061,3 @@ var ft = new FileTransfer();

/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
var hash = __webpack_require__(3);
var Promise = null;
var isCordova = typeof cordova !== 'undefined';
/* Cordova File Cache x */
function FileCache(options){
var self = this;
// cordova-promise-fs
this._fs = options.fs;
if(!this._fs) {
throw new Error('Missing required option "fs". Add an instance of cordova-promise-fs.');
}
// Use Promises from fs.
Promise = this._fs.Promise;
// 'mirror' mirrors files structure from "serverRoot" to "localRoot"
// 'hash' creates a 1-deep filestructure, where the filenames are hashed server urls (with extension)
this._mirrorMode = options.mode !== 'hash';
this._retry = options.retry || [500,1500,8000];
this._cacheBuster = !!options.cacheBuster;
// normalize path
this.localRoot = this._fs.normalize(options.localRoot || 'data');
this.serverRoot = this._fs.normalize(options.serverRoot || '');
// set internal variables
this._downloading = []; // download promises
this._added = []; // added files
this._cached = {}; // cached files
// list existing cache contents
this.ready = this._fs.ensure(this.localRoot)
.then(function(entry){
self.localInternalURL = isCordova? entry.toInternalURL(): entry.toURL();
self.localUrl = entry.toURL();
return self.list();
});
}
/**
* Helper to cache all 'internalURL' and 'URL' for quick synchronous access
* to the cached files.
*/
FileCache.prototype.list = function list(){
var self = this;
return new Promise(function(resolve,reject){
self._fs.list(self.localRoot,'rfe').then(function(entries){
self._cached = {};
entries = entries.map(function(entry){
var fullPath = self._fs.normalize(entry.fullPath);
self._cached[fullPath] = {
toInternalURL: isCordova? entry.toInternalURL(): entry.toURL(),
toURL: entry.toURL(),
};
return fullPath;
});
resolve(entries);
},function(){
resolve([]);
});
});
};
FileCache.prototype.add = function add(urls){
if(!urls) urls = [];
if(typeof urls === 'string') urls = [urls];
var self = this;
urls.forEach(function(url){
url = self.toServerURL(url);
if(self._added.indexOf(url) === -1) {
self._added.push(url);
}
});
return self.isDirty();
};
FileCache.prototype.remove = function remove(urls,returnPromises){
if(!urls) urls = [];
var promises = [];
if(typeof urls === 'string') urls = [urls];
var self = this;
urls.forEach(function(url){
var index = self._added.indexOf(self.toServerURL(url));
if(index >= 0) self._added.splice(index,1);
var path = self.toPath(url);
promises.push(self._fs.remove(path));
delete self._cached[path];
});
return returnPromises? Promise.all(promises): self.isDirty();
};
FileCache.prototype.getDownloadQueue = function(){
var self = this;
var queue = self._added.filter(function(url){
return !self.isCached(url);
});
return queue;
};
FileCache.prototype.getAdded = function() {
return this._added;
};
FileCache.prototype.isDirty = function isDirty(){
return this.getDownloadQueue().length > 0;
};
FileCache.prototype.download = function download(onprogress){
var fs = this._fs;
var self = this;
self.abort();
return new Promise(function(resolve,reject){
// make sure cache directory exists and that
// we have retrieved the latest cache contents
// to avoid downloading files we already have!
fs.ensure(self.localRoot).then(function(){
return self.list();
}).then(function(){
// no dowloads needed, resolve
if(!self.isDirty()) {
resolve(self);
return;
}
// keep track of number of downloads!
var queue = self.getDownloadQueue();
var started = [];
var index = self._downloading.length;
var done = self._downloading.length;
var total = self._downloading.length + queue.length;
// download every file in the queue (which is the diff from _added with _cached)
queue.forEach(function(url){
var path = self.toPath(url);
// augment progress event with index/total stats
var onSingleDownloadProgress;
if(typeof onprogress === 'function') {
onSingleDownloadProgress = function(ev){
ev.queueIndex = index;
ev.queueSize = total;
ev.url = url;
ev.path = path;
ev.percentage = index / total;
if(ev.loaded > 0 && ev.total > 0 && index !== total){
ev.percentage += (ev.loaded / ev.total) / total;
}
if(started.indexOf(url) < 0) {
started.push(url);
index++;
}
onprogress(ev);
};
}
// callback
var onDone = function(){
done++;
// when we're done
if(done === total) {
// reset downloads
self._downloading = [];
// check if we got everything
self.list().then(function(){
// final progress event!
if(onSingleDownloadProgress) onSingleDownloadProgress(new ProgressEvent());
// Yes, we're not dirty anymore!
if(!self.isDirty()) {
resolve(self);
// Aye, some files got left behind!
} else {
reject(self.getDownloadQueue());
}
},reject);
}
};
var downloadUrl = url;
if(self._cacheBuster) downloadUrl += "?"+Date.now();
var download = fs.download(downloadUrl,path,{retry:self._retry},onSingleDownloadProgress);
download.then(onDone,onDone);
self._downloading.push(download);
});
},reject);
});
};
FileCache.prototype.abort = function abort(){
this._downloading.forEach(function(download){
download.abort();
});
this._downloading = [];
};
FileCache.prototype.isCached = function isCached(url){
url = this.toPath(url);
return !!this._cached[url];
};
FileCache.prototype.clear = function clear(){
var self = this;
this._cached = {};
return this._fs.removeDir(this.localRoot).then(function(){
return self._fs.ensure(self.localRoot);
});
};
/**
* Helpers to output to various formats
*/
FileCache.prototype.toInternalURL = function toInternalURL(url){
path = this.toPath(url);
if(this._cached[path]) return this._cached[path].toInternalURL;
return url;
};
FileCache.prototype.get = function get(url){
path = this.toPath(url);
if(this._cached[path]) return this._cached[path].toInternalURL;
return this.toServerURL(url);
};
FileCache.prototype.toDataURL = function toDataURL(url){
return this._fs.toDataURL(this.toPath(url));
};
FileCache.prototype.toURL = function toURL(url){
path = this.toPath(url);
return this._cached[path]? this._cached[path].toURL: url;
};
FileCache.prototype.toServerURL = function toServerURL(path){
path = this._fs.normalize(path);
return path.indexOf('://') < 0? this.serverRoot + path: path;
};
/**
* Helper to transform remote URL to a local path (for cordova-promise-fs)
*/
FileCache.prototype.toPath = function toPath(url){
if(this._mirrorMode) {
url = url = this._fs.normalize(url || '');
len = this.serverRoot.length;
if(url.substr(0,len) !== this.serverRoot) {
return this.localRoot + url;
} else {
return this.localRoot + url.substr(len);
}
} else {
return this.localRoot + hash(url) + url.substr(url.lastIndexOf('.'));
}
};
module.exports = FileCache;
/***/ },

@@ -1126,2 +1135,2 @@ /* 3 */

/***/ }
/******/ ])
/******/ ]);

@@ -5,10 +5,10 @@ var CordovaPromiseFS =

/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)

@@ -20,23 +20,23 @@ /******/ var module = installedModules[moduleId] = {

/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports

@@ -93,3 +93,3 @@ /******/ return __webpack_require__(0);

var Promise = options.Promise || window.Promise;
if(!Promise) { throw new Error("No Promise library given in options.Promise"); }
if(typeof Promise === 'undefined') { throw new Error("No Promise library given in options.Promise"); }

@@ -180,3 +180,3 @@ /* default options */

folders = folders.split('/').filter(function(folder) {
return folder && folder.length > 0 && folder[0] !== '.';
return folder && folder.length > 0 && folder !== '.' && folder !== '..';
});

@@ -292,3 +292,3 @@ __createDir(fs.root,folders,resolve,reject);

path = normalize(path);
return 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path;
return path.indexOf('://') < 0? 'cdvfile://localhost/'+(options.persistent? 'persistent/':'temporary/') + path: path;
};

@@ -453,4 +453,3 @@

}
serverUrl = encodeURI(serverUrl);
if(isCordova) localPath = toInternalURLSync(localPath);
if(isCordova && localPath.indexOf('://') < 0) localPath = toInternalURLSync(localPath);

@@ -462,2 +461,5 @@ transferOptions = transferOptions || {};

transferOptions.retry = transferOptions.retry.concat();
if(!transferOptions.file && !isDownload){
transferOptions.fileName = filename(localPath);
}

@@ -537,3 +539,4 @@ var ft = new FileTransfer();

/***/ }
/******/ ])
/******/ ]);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc