Huge News!Announcing our $40M Series B led by Abstract Ventures.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.1.0 to 0.1.1

bower.json

44

index.js

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

return new Promise(function(resolve,reject){
if(self.newManifest && !newManifest) {
console.warn('CordovaAppLoader: Already checked for new manifest.');
resolve(self.newManifest);
return;
}
if(typeof newManifest === "string") {

@@ -48,9 +43,6 @@ self.newManifestUrl = newManifest;

if(!newManifest.files){
reject('Downloaded Manifest is has no "files" attribute.');
reject('Downloaded Manifest has no "files" attribute.');
return;
}
// Save the new Manifest
self.newManifest = newManifest;
self.newManifest.root = self.cache.toInternalURL('/') + (self.newManifest.root || '');
// Create the diff

@@ -70,3 +62,10 @@ self._toBeDownloaded = Object.keys(newManifest.files)

resolve(self.canDownload() || self.canUpdate());
if(self._toBeDeleted.length > 0){
// Save the new Manifest
self.newManifest = newManifest;
self.newManifest.root = self.cache.toInternalURL('/') + (self.newManifest.root || '');
resolve(true);
} else {
resolve(false);
}
},reject);

@@ -83,3 +82,3 @@ }

AppLoader.prototype.canDownload = function(){
return this._toBeDeleted.length > 0 || this.cache.isDirty();
return !!this.newManifest;
};

@@ -93,2 +92,8 @@

var self = this;
if(!self.canDownload()) {
return Promise.resolve(null);
}
// we will delete files, which will invalidate the current manifest...
localStorage.removeItem('manifest');
this.manifest.files = Manifest.files = {};
return self.cache.remove(self._toBeDeleted,true)

@@ -100,6 +105,4 @@ .then(function(){

self._toBeDeleted = [];
// We deleted stuff, so we MUST load new manifest on next load!
localStorage.setItem('manifest',JSON.stringify(self.newManifest));
self._updateReady = true;
return self;
return self.newManifest;
});

@@ -118,2 +121,13 @@ };

AppLoader.prototype.clear = function(){
localStorage.removeItem('manifest');
return this.cache.clear();
};
AppLoader.prototype.reset = function(){
return this.clear().then(function(){
location.reload();
});
};
module.exports = AppLoader;
{
"name": "cordova-app-loader",
"version": "0.1.0",
"version": "0.1.1",
"description": "Cordova App Loader - remote update your cordova app",

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

"dependencies": {
"cordova-file-cache": "^0.1.1"
"cordova-file-cache": "^0.2.1"
}
}

@@ -31,9 +31,6 @@ cordova-app-loader

cordova plugin add org.apache.cordova.file-transfer
cordova serve
# in a new terminal tab:
cordova run ios
```
If you want to run on a real device, modify `serverRoot` in `www/test/test.js` to point to your local server!
Want to run your own server? Modify `serverRoot` in `www/test/test.js`!

@@ -40,0 +37,0 @@ ## Usage

@@ -80,7 +80,2 @@ var CordovaAppLoader =

return new Promise(function(resolve,reject){
if(self.newManifest && !newManifest) {
console.warn('CordovaAppLoader: Already checked for new manifest.');
resolve(self.newManifest);
return;
}
if(typeof newManifest === "string") {

@@ -95,9 +90,6 @@ self.newManifestUrl = newManifest;

if(!newManifest.files){
reject('Downloaded Manifest is has no "files" attribute.');
reject('Downloaded Manifest has no "files" attribute.');
return;
}
// Save the new Manifest
self.newManifest = newManifest;
self.newManifest.root = self.cache.toInternalURL('/') + (self.newManifest.root || '');
// Create the diff

@@ -117,3 +109,10 @@ self._toBeDownloaded = Object.keys(newManifest.files)

resolve(self.canDownload() || self.canUpdate());
if(self._toBeDeleted.length > 0){
// Save the new Manifest
self.newManifest = newManifest;
self.newManifest.root = self.cache.toInternalURL('/') + (self.newManifest.root || '');
resolve(true);
} else {
resolve(false);
}
},reject);

@@ -130,3 +129,3 @@ }

AppLoader.prototype.canDownload = function(){
return this._toBeDeleted.length > 0 || this.cache.isDirty();
return !!this.newManifest;
};

@@ -140,2 +139,8 @@

var self = this;
if(!self.canDownload()) {
return Promise.resolve(null);
}
// we will delete files, which will invalidate the current manifest...
localStorage.removeItem('manifest');
this.manifest.files = Manifest.files = {};
return self.cache.remove(self._toBeDeleted,true)

@@ -147,6 +152,4 @@ .then(function(){

self._toBeDeleted = [];
// We deleted stuff, so we MUST load new manifest on next load!
localStorage.setItem('manifest',JSON.stringify(self.newManifest));
self._updateReady = true;
return self;
return self.newManifest;
});

@@ -165,2 +168,13 @@ };

AppLoader.prototype.clear = function(){
localStorage.removeItem('manifest');
return this.cache.clear();
};
AppLoader.prototype.reset = function(){
return this.clear().then(function(){
location.reload();
});
};
module.exports = AppLoader;

@@ -167,0 +181,0 @@

var fs = new CordovaPromiseFS({});
var SERVER = 'http://data.madebymark.nl/cordova-app-loader/';

@@ -7,3 +8,3 @@ var loader = window.loader = new CordovaAppLoader({

localRoot: 'app',
serverRoot: 'http://localhost:8000/ios/www/',
serverRoot: SERVER,
mode: 'mirror'

@@ -27,3 +28,3 @@ });

var url = $(ev.target).attr('manifest');
loader.check(url).then(setStatus,setStatus);
loader.check(SERVER+url).then(setStatus,setStatus);
});

@@ -40,3 +41,3 @@

$('body').on('click','.factory',function(){
localStorage.removeItem('manifest');
loader.reset();
});

@@ -43,0 +44,0 @@

Sorry, the diff of this file is not supported yet

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