2015-12-22 20:41:40 +00:00
|
|
|
|
es5-ff-spa-loader
|
2015-12-23 00:16:54 +00:00
|
|
|
|
=========
|
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
A javascript library providing server defined loading of assets for a single page application.
|
2015-12-23 00:16:54 +00:00
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
npm --save install es5-ff-spa-loader
|
2015-12-23 00:16:54 +00:00
|
|
|
|
|
2016-01-18 01:06:24 +00:00
|
|
|
|
Then use the dist/es5-ff-spa-loader.min.js script inline in the index.
|
2015-12-23 00:16:54 +00:00
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
## Features
|
2015-12-23 00:16:54 +00:00
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
* Assets caching for offline use.
|
|
|
|
|
* Assets hashing for fast syncing.
|
|
|
|
|
* Assets types: js,css,cssData
|
|
|
|
|
* Caching backends: null,localStorage,webSqlDB,sqllite
|
|
|
|
|
* Server url question ui.
|
|
|
|
|
* Loader error ui.
|
|
|
|
|
* Build-in Cordova booting.
|
|
|
|
|
* Build-in AngularJS booting.
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
### Usage Multi Server (Minimal)
|
2016-01-14 23:59:00 +00:00
|
|
|
|
|
2016-01-16 17:24:37 +00:00
|
|
|
|
FFSpaLoader.options.server.assets = '/api/path/to/spa/client/resources';
|
|
|
|
|
FFSpaLoader.start();
|
2016-01-14 23:59:00 +00:00
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
### Usage Single Server
|
2016-01-14 23:59:00 +00:00
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
FFSpaLoader.options.server.url = 'http://myserver';
|
|
|
|
|
FFSpaLoader.options.server.assets = '/api/path/to/spa/client/resources';
|
|
|
|
|
FFSpaLoader.start();
|
|
|
|
|
|
|
|
|
|
### Usage Angular
|
2016-01-14 23:59:00 +00:00
|
|
|
|
|
2016-01-16 17:24:37 +00:00
|
|
|
|
FFSpaLoader.options.debug.enable = true;
|
|
|
|
|
FFSpaLoader.options.boot.angular.modules.push('exampleUI');
|
|
|
|
|
FFSpaLoader.options.server.url = 'http://myserver';
|
|
|
|
|
FFSpaLoader.options.server.assets = '/api/path/to/spa/client/resources';
|
2016-01-14 23:59:00 +00:00
|
|
|
|
FFSpaLoader.start(function() {
|
2016-01-16 17:24:37 +00:00
|
|
|
|
console.log('FFExample.boot done');
|
2016-01-18 00:06:42 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
## Assets format
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"resources": [
|
|
|
|
|
{
|
|
|
|
|
"url": "/static/js/assets.js",
|
|
|
|
|
"type": "js",
|
|
|
|
|
"hash": -164319899
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"url": "/static/css/assets.css",
|
|
|
|
|
"type": "css",
|
|
|
|
|
"hash": 1391550981
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"url": "/static/css/assets-data.css",
|
|
|
|
|
"type": "cssData",
|
|
|
|
|
"hash": 1371811412
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
The hash key is required as only on hash change the resource will be downloaded again, so multiple small files makes updates faster.
|
2016-01-14 23:59:00 +00:00
|
|
|
|
|
2015-12-23 00:16:54 +00:00
|
|
|
|
|
|
|
|
|
## Options
|
|
|
|
|
|
2016-01-20 19:35:43 +00:00
|
|
|
|
The available FFSpaLoader.options.* values;
|
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
* debug.enable = Enable debug output. (default: false)
|
|
|
|
|
* debug.handler = Prints/log debug message. (default: console.log)
|
|
|
|
|
* debug.prefix = Debug message prefix. (default: 'FFSpaLoader.')
|
|
|
|
|
* error.handler = The error handler. (default: internal error handler ui)
|
2016-01-20 20:57:05 +00:00
|
|
|
|
* error.title = The error title. (default: 'Loader ');
|
2016-01-18 00:06:42 +00:00
|
|
|
|
* error.style = The error ui css style. (default: red border box)
|
|
|
|
|
* boot.cordova.enable = Use deviceready event to boot when cordova is detected. (default: true)
|
2016-01-20 19:35:43 +00:00
|
|
|
|
* boot.cordova.timeout = Boot after (if<0=no-)timeout when deviceready event is not received. (default: -1)
|
2016-01-18 00:06:42 +00:00
|
|
|
|
* boot.cordova.flag = The window flag which is set when cordova is booted. (default: 'FFCordovaDevice')
|
|
|
|
|
* boot.angular.enable = Auto bootstrap angular modules. (default: true)
|
|
|
|
|
* boot.angular.modules = The angular modules to boot. (default: empty)
|
|
|
|
|
* server.url = The server url like 'https://myhost', when null the user will get promted to input it. (default: null)
|
|
|
|
|
* server.assets = The server path to the assets resources definition file, is required (default: null)
|
2016-01-18 21:41:52 +00:00
|
|
|
|
* server.timeout = The timeout to download the server resources. (default: 4096)
|
2016-01-18 00:06:42 +00:00
|
|
|
|
* server.flag = The window flag which is set when the server.url is know. (default: 'FFServerUrl')
|
|
|
|
|
* server.question.transport = The transport to prefix the server.url with. (default: 'http://')
|
|
|
|
|
* server.question.title = The question ui title. (default: 'Server')
|
|
|
|
|
* server.question.text = The question ui text. (default: 'Please provide the server name;')
|
|
|
|
|
* server.question.style = The question ui css style.(note: pending change) (default: green border box)
|
2016-01-21 00:40:15 +00:00
|
|
|
|
* cache.meta = The cache backend for the meta information(server.url+content), null is auto select. (default: null)
|
2016-01-18 00:06:42 +00:00
|
|
|
|
* cache.js = The cache backend for for js, null is auto select. (default: null)
|
|
|
|
|
* cache.css = The cache backend for for css, null is auto select. (default: null)
|
|
|
|
|
* cache.cssData = The cache backend for for cssData, null is auto select. (default: null)
|
|
|
|
|
|
2016-01-20 19:35:43 +00:00
|
|
|
|
|
|
|
|
|
## Factory
|
|
|
|
|
|
|
|
|
|
The available FFSpaLoader.factory.* functions;
|
|
|
|
|
|
|
|
|
|
* detect.localStorage() = Checks is localStorage is working.
|
|
|
|
|
* detect.openDatabase() = Checks if openDatabase is defined.
|
|
|
|
|
* detect.sqlitePlugin() = Checks if sqlitePlugin is defined.
|
|
|
|
|
* detect.cordova() = Checks if cordova is defined.
|
|
|
|
|
* detect.cordovaDevice() = Checks if cordovaDevive window flag is defined which will be set by the buildin cordova boot code.
|
|
|
|
|
* cache.localStorage() = Creates an localStorage service.
|
|
|
|
|
* cache.websql(opt) = Creates an websql service.
|
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
## Cache Config
|
|
|
|
|
|
|
|
|
|
Per default all cache type as in auto select mode which detect and used the following;
|
|
|
|
|
|
|
|
|
|
* sqlitePlugin
|
|
|
|
|
* openDatabase
|
|
|
|
|
* localStorage
|
|
|
|
|
* none
|
|
|
|
|
|
2016-01-18 01:06:24 +00:00
|
|
|
|
More custom schemas are possible like; (todo: needs testing)
|
2016-01-18 00:06:42 +00:00
|
|
|
|
|
2016-01-21 00:40:15 +00:00
|
|
|
|
FFSpaLoader.options.cache.meta = false;
|
2016-01-18 00:06:42 +00:00
|
|
|
|
FFSpaLoader.options.cache.js = false;
|
|
|
|
|
FFSpaLoader.options.cache.css = false;
|
|
|
|
|
FFSpaLoader.options.cache.cssData = false;
|
|
|
|
|
|
|
|
|
|
if (FFSpaLoader.factory.detect.localStorage()) {
|
|
|
|
|
FFSpaLoader.options.cache.css = FFSpaLoader.factory.cache.localStorage;
|
|
|
|
|
FFSpaLoader.options.cache.cssData = FFSpaLoader.factory.cache.localStorage;
|
|
|
|
|
}
|
|
|
|
|
FFSpaLoader.options.server.assets = '/api/path/to/spa/client/resources';
|
|
|
|
|
FFSpaLoader.start();
|
|
|
|
|
|
2015-12-23 00:16:54 +00:00
|
|
|
|
|
|
|
|
|
## Example Application
|
|
|
|
|
|
2016-01-18 00:06:42 +00:00
|
|
|
|
There is a fully working nodejs example application in the example folder.
|
2015-12-23 00:16:54 +00:00
|
|
|
|
|
2016-01-16 17:24:37 +00:00
|
|
|
|
## Tested Browsers
|
|
|
|
|
|
|
|
|
|
* Chromium 46
|
|
|
|
|
* Iceweasel 43
|
|
|
|
|
* Opera 12 Presto
|
2016-01-20 20:57:05 +00:00
|
|
|
|
* IE 11 Edge
|
2016-01-16 17:24:37 +00:00
|
|
|
|
* Android 5 in Cordova
|
2016-01-17 20:57:59 +00:00
|
|
|
|
|
|
|
|
|
## Todo
|
|
|
|
|
|
|
|
|
|
* test in production
|
|
|
|
|
* Server header set+check support
|
|
|
|
|
* Redo css(?divs) of server question
|
2016-01-20 19:35:43 +00:00
|
|
|
|
* Add table+instance websql options so it can also be used in application code.
|
2016-01-17 20:57:59 +00:00
|
|
|
|
* Add more tests
|
|
|
|
|
* css: set tag.media = 'only you';
|
|
|
|
|
* css: add media in resouces
|
|
|
|
|
* Add in browser tests
|
2016-01-16 17:24:37 +00:00
|
|
|
|
|
2015-12-23 00:16:54 +00:00
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
|
|
In lieu of a formal styleguide, take care to maintain the existing coding style.
|
|
|
|
|
Add unit tests for any new or changed functionality. Lint and test your code.
|
|
|
|
|
|
|
|
|
|
## Release History
|
|
|
|
|
|
2016-01-20 19:35:43 +00:00
|
|
|
|
### 0.0.4
|
2016-01-21 00:40:15 +00:00
|
|
|
|
* Added auto cache clean code
|
2016-01-20 19:35:43 +00:00
|
|
|
|
* Disable cordova timeout per default.
|
|
|
|
|
* Remove unused mobileAgent detect.
|
2016-01-21 00:40:15 +00:00
|
|
|
|
* Fixed cached resources injection order.
|
2016-01-20 19:35:43 +00:00
|
|
|
|
|
|
|
|
|
|
2016-01-18 01:06:24 +00:00
|
|
|
|
### 0.0.3
|
2016-01-20 19:35:43 +00:00
|
|
|
|
* Fixed example script path.
|
2016-01-18 01:06:24 +00:00
|
|
|
|
|
2016-01-18 00:25:49 +00:00
|
|
|
|
### 0.0.2
|
2016-01-20 19:35:43 +00:00
|
|
|
|
* Fixed example size.
|
2016-01-18 00:25:49 +00:00
|
|
|
|
|
|
|
|
|
### 0.0.1
|
2016-01-20 19:35:43 +00:00
|
|
|
|
* Initial release.
|