Removed auto service-worker feature
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 647dc0f..667d9ff 100644
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -83,8 +83,6 @@
// copy manifest file to platform_www
fs.writeFileSync(path.join(platform_www, 'manifest.json'),
JSON.stringify(manifest, null, 2), 'utf-8');
- // copy service worker
- shell.cp(path.join(ROOT, 'bin/template/www', 'cordova-sw.js'), platform_www);
return Promise.resolve();
};
diff --git a/bin/template/cordova/lib/build.js b/bin/template/cordova/lib/build.js
index 64e5198..01f3fb1 100644
--- a/bin/template/cordova/lib/build.js
+++ b/bin/template/cordova/lib/build.js
@@ -19,9 +19,7 @@
* under the License.
*/
-var fs = require('fs');
var path = require('path');
-var shell = require('shelljs');
var check_reqs = require('./check_reqs');
/**
@@ -29,32 +27,7 @@
* Creates a zip file int platform/build folder
*/
module.exports.run = function () {
-
- var resultP = check_reqs.run();
-
- resultP.then(function () {
- var wwwPath = path.join(__dirname, '../../www');
-
- // generate a generic service worker
- var lsdir = shell.find(wwwPath);
- var pathLength = wwwPath.length;
- var cleanedFileList = lsdir.filter(function (elem) {
- // skip directory names, and cordova-js-src
- return !fs.statSync(elem).isDirectory() &&
- elem.indexOf('cordova-js-src') < 0;
- }).map(function (elem) {
- return elem.substr(pathLength);
- });
-
- var swJSPath = path.join(wwwPath, 'cordova-sw.js');
- var swJS = fs.readFileSync(swJSPath, 'utf8');
-
- swJS = swJS.replace('%CACHE_VERSION%', Date.now());
- swJS = swJS.replace("['CACHE_VALUES']", JSON.stringify(cleanedFileList, null, 4));
-
- fs.writeFileSync(swJSPath, swJS, 'utf8');
- });
- return resultP;
+ return check_reqs.run();
};
module.exports.help = function () {
diff --git a/bin/template/www/cordova-sw.js b/bin/template/www/cordova-sw.js
deleted file mode 100644
index 9740fb1..0000000
--- a/bin/template/www/cordova-sw.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-'License'); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-
-// Note, these will be updated automatically at build time
-var CACHE_VERSION = '%CACHE_VERSION%';
-var CACHE_LIST = ['CACHE_VALUES'];
-
-this.addEventListener('install', function (event) {
- // Perform install steps
- console.log('cordova service worker is installing.');
- event.waitUntil(caches.open(CACHE_VERSION) /* eslint no-undef : 0 */
- .then(function (cache) {
- return cache.addAll(CACHE_LIST);
- }));
-});
-
-this.addEventListener('activate', function (event) {
- // Perform activate steps
- console.log('cordova service worker is activated.');
-});
-
-this.addEventListener('fetch', function (event) {
- console.log('cordova service worker : fetch : ' + event.request.url);
-
- event.respondWith(caches.match(event.request).then(function (response) { /* eslint no-undef : 0 */
- // Cache hit? return response else fetch it
- return response || fetch(event.request); /* eslint no-undef : 0 */
- }));
-});
diff --git a/cordova-js-src/platform.js b/cordova-js-src/platform.js
index 3494cea..96eb943 100644
--- a/cordova-js-src/platform.js
+++ b/cordova-js-src/platform.js
@@ -24,26 +24,6 @@
cordovaVersion: '4.2.0', // cordova-js
bootstrap: function() {
-
- var cache = navigator.serviceWorker.register;
- var cacheCalled = false;
- navigator.serviceWorker.register = function() {
- cacheCalled = true;
- navigator.serviceWorker.register = cache;
- return cache.apply(navigator.serviceWorker,arguments);
- }
-
- document.addEventListener('deviceready',function(){
- if(!cacheCalled) {
- navigator.serviceWorker.register('/cordova-sw.js').then(function(registration) {
- // Registration was successful
- console.log('ServiceWorker registration successful with scope: ', registration.scope);
- }, function(err) {
- // registration failed :(
- console.log('ServiceWorker registration failed: ', err);
- });
- }
- });
var modulemapper = require('cordova/modulemapper');
var channel = require('cordova/channel');