mirror of
https://github.com/a2nt/silverstripe-progressivewebapp.git
synced 2024-10-22 11:05:45 +02:00
IMPR: More debug logging
This commit is contained in:
parent
7eff45c737
commit
db8bb88bbc
106
client/dist/app.js
vendored
106
client/dist/app.js
vendored
@ -1,105 +1 @@
|
||||
/******/ (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)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = 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;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "/mnt/data/srv/dist/web/nysca/vendor/a2nt/silverstripe-progressivewebapp/client/dist";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = "./client/src/app.js");
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ "./client/src/app.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
var baseHref = (document.getElementsByTagName('base')[0] || {}).href;
|
||||
|
||||
if (baseHref) {
|
||||
navigator.serviceWorker.register("".concat(baseHref, "sw.js")).then(function () {
|
||||
console.log('Service Worker Registered');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
//# sourceMappingURL=app.js.map
|
||||
!function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="/mnt/data/srv/dist/web/nysca/vendor/a2nt/silverstripe-progressivewebapp/client/dist",t(t.s="./client/src/app.js")}({"./client/src/app.js":function(e,r){if("serviceWorker"in navigator){var t=(document.getElementsByTagName("base")[0]||{}).href;t&&navigator.serviceWorker.register("".concat(t,"sw.js")).then((function(){console.log("Service Worker Registered")}))}}});
|
1
client/dist/app.js.map
vendored
1
client/dist/app.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./client/src/app.js"],"names":["navigator","baseHref","document","getElementsByTagName","href","serviceWorker","register","then","console","log"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;AClFA,IAAI,mBAAmBA,SAAvB,EAAkC;AAChC,MAAIC,QAAQ,GAAG,CAACC,QAAQ,CAACC,oBAAT,CAA8B,MAA9B,EAAsC,CAAtC,KAA4C,EAA7C,EAAiDC,IAAhE;;AACA,MAAIH,QAAJ,EAAc;AACZD,aAAS,CAACK,aAAV,CAAwBC,QAAxB,WAAoCL,QAApC,YAAqDM,IAArD,CAA0D,YAAM;AAC9DC,aAAO,CAACC,GAAR,CAAY,2BAAZ;AACD,KAFD;AAGD;AACF,C","file":"app.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/mnt/data/srv/dist/web/nysca/vendor/a2nt/silverstripe-progressivewebapp/client/dist\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./client/src/app.js\");\n","if ('serviceWorker' in navigator) {\n var baseHref = (document.getElementsByTagName('base')[0] || {}).href;\n if (baseHref) {\n navigator.serviceWorker.register(`${baseHref}sw.js`).then(() => {\n console.log('Service Worker Registered');\n });\n }\n}\n"],"sourceRoot":""}
|
221
client/dist/sw.js
vendored
221
client/dist/sw.js
vendored
@ -1,220 +1 @@
|
||||
/******/ (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)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = 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;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "/mnt/data/srv/dist/web/nysca/vendor/a2nt/silverstripe-progressivewebapp/client/dist";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = "./client/src/sw.js");
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ "./client/src/sw.js":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
// caches polyfill because it is not added to native yet!
|
||||
var caches = __webpack_require__("./client/src/thirdparty/serviceworker-caches.js");
|
||||
|
||||
if (typeof self.CACHE_NAME !== 'string') {
|
||||
throw new Error('Cache Name cannot be empty');
|
||||
}
|
||||
|
||||
self.addEventListener('fetch', function (event) {
|
||||
// Clone the request for fetch and cache
|
||||
// A request is a stream and can be consumed only once.
|
||||
var fetchRequest = event.request.clone(),
|
||||
cacheRequest = event.request.clone(); // Respond with content from fetch or cache
|
||||
|
||||
event.respondWith( // Try fetch
|
||||
fetch(fetchRequest) // when fetch is successful, we update the cache
|
||||
.then(function (response) {
|
||||
// A response is a stream and can be consumed only once.
|
||||
// Because we want the browser to consume the response,
|
||||
// as well as cache to consume the response, we need to
|
||||
// clone it so we have 2 streams
|
||||
var responseToCache = response.clone(); // and update the cache
|
||||
|
||||
caches.open(self.CACHE_NAME).then(function (cache) {
|
||||
// Clone the request again to use it
|
||||
// as the key for our cache
|
||||
var cacheSaveRequest = event.request.clone();
|
||||
cache.put(cacheSaveRequest, responseToCache);
|
||||
}); // Return the response stream to be consumed by browser
|
||||
|
||||
return response;
|
||||
}) // when fetch times out or fails
|
||||
.catch(function (err) {
|
||||
// Return the promise which
|
||||
// resolves on a match in cache for the current request
|
||||
// or rejects if no matches are found
|
||||
return caches.match(cacheRequest);
|
||||
}));
|
||||
}); // Now we need to clean up resources in the previous versions
|
||||
// of Service Worker scripts
|
||||
|
||||
self.addEventListener('activate', function (event) {
|
||||
// Destroy the cache
|
||||
event.waitUntil(caches.delete(self.CACHE_NAME));
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./client/src/thirdparty/serviceworker-caches.js":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
if (!Cache.prototype.add) {
|
||||
Cache.prototype.add = function add(request) {
|
||||
return this.addAll([request]);
|
||||
};
|
||||
}
|
||||
|
||||
if (!Cache.prototype.addAll) {
|
||||
Cache.prototype.addAll = function addAll(requests) {
|
||||
var cache = this; // Since DOMExceptions are not constructable:
|
||||
|
||||
function NetworkError(message) {
|
||||
this.name = 'NetworkError';
|
||||
this.code = 19;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
NetworkError.prototype = Object.create(Error.prototype);
|
||||
return Promise.resolve().then(function () {
|
||||
if (arguments.length < 1) throw new TypeError(); // Simulate sequence<(Request or USVString)> binding:
|
||||
|
||||
var sequence = [];
|
||||
requests = requests.map(function (request) {
|
||||
if (request instanceof Request) {
|
||||
return request;
|
||||
} else {
|
||||
return String(request); // may throw TypeError
|
||||
}
|
||||
});
|
||||
return Promise.all(requests.map(function (request) {
|
||||
if (typeof request === 'string') {
|
||||
request = new Request(request);
|
||||
}
|
||||
|
||||
var scheme = new URL(request.url).protocol;
|
||||
|
||||
if (scheme !== 'http:' && scheme !== 'https:') {
|
||||
throw new NetworkError('Invalid scheme');
|
||||
}
|
||||
|
||||
return fetch(request.clone());
|
||||
}));
|
||||
}).then(function (responses) {
|
||||
// TODO: check that requests don't overwrite one another
|
||||
// (don't think this is possible to polyfill due to opaque responses)
|
||||
return Promise.all(responses.map(function (response, i) {
|
||||
return cache.put(requests[i], response);
|
||||
}));
|
||||
}).then(function () {
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
if (!CacheStorage.prototype.match) {
|
||||
// This is probably vulnerable to race conditions (removing caches etc)
|
||||
CacheStorage.prototype.match = function match(request, opts) {
|
||||
var caches = this;
|
||||
return this.keys().then(function (cacheNames) {
|
||||
var match;
|
||||
return cacheNames.reduce(function (chain, cacheName) {
|
||||
return chain.then(function () {
|
||||
return match || caches.open(cacheName).then(function (cache) {
|
||||
return cache.match(request, opts);
|
||||
}).then(function (response) {
|
||||
match = response;
|
||||
return match;
|
||||
});
|
||||
});
|
||||
}, Promise.resolve());
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = self.caches;
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
//# sourceMappingURL=sw.js.map
|
||||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/mnt/data/srv/dist/web/nysca/vendor/a2nt/silverstripe-progressivewebapp/client/dist",n(n.s="./client/src/sw.js")}({"./client/src/lib/log.js":function(e,t){e.exports=function(e){debug&&console.log(e)}},"./client/src/sw.js":function(e,t,n){var r=n("./client/src/lib/log.js"),o=n("./client/src/thirdparty/serviceworker-caches.js");if(debug&&(r("SW: debug is on"),r("SW: CACHE_NAME: ".concat(CACHE_NAME)),r("SW: appDomain: ".concat(appDomain)),r("SW: lang: ".concat(lang))),"string"!==typeof self.CACHE_NAME)throw new Error("Cache Name cannot be empty");self.addEventListener("fetch",(function(e){var t=e.request.clone(),n=e.request.clone();e.respondWith(fetch(t).then((function(t){var n=t.clone();return o.open(self.CACHE_NAME).then((function(t){var r=e.request.clone();t.put(r,n)})),t})).catch((function(e){return r("SW: fetch failed"),o.match(n)})))})),self.addEventListener("activate",(function(e){r("SW: activated: ".concat(version)),e.waitUntil(o.delete(self.CACHE_NAME))})),self.addEventListener("install",(function(e){r("SW: installing version: ".concat(version))}))},"./client/src/thirdparty/serviceworker-caches.js":function(e,t){Cache.prototype.add||(Cache.prototype.add=function(e){return this.addAll([e])}),Cache.prototype.addAll||(Cache.prototype.addAll=function(e){var t=this;function n(e){this.name="NetworkError",this.code=19,this.message=e}return n.prototype=Object.create(Error.prototype),Promise.resolve().then((function(){if(arguments.length<1)throw new TypeError;return e=e.map((function(e){return e instanceof Request?e:String(e)})),Promise.all(e.map((function(e){"string"===typeof e&&(e=new Request(e));var t=new URL(e.url).protocol;if("http:"!==t&&"https:"!==t)throw new n("Invalid scheme");return fetch(e.clone())})))})).then((function(n){return Promise.all(n.map((function(n,r){return t.put(e[r],n)})))})).then((function(){}))}),CacheStorage.prototype.match||(CacheStorage.prototype.match=function(e,t){var n=this;return this.keys().then((function(r){var o;return r.reduce((function(r,c){return r.then((function(){return o||n.open(c).then((function(n){return n.match(e,t)})).then((function(e){return o=e}))}))}),Promise.resolve())}))}),e.exports=self.caches}});
|
1
client/dist/sw.js.map
vendored
1
client/dist/sw.js.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./client/src/sw.js","webpack:///./client/src/thirdparty/serviceworker-caches.js"],"names":["caches","require","self","CACHE_NAME","Error","addEventListener","event","fetchRequest","request","clone","cacheRequest","respondWith","fetch","then","response","responseToCache","open","cache","cacheSaveRequest","put","catch","err","match","waitUntil","delete","Cache","prototype","add","addAll","requests","NetworkError","message","name","code","Object","create","Promise","resolve","arguments","length","TypeError","sequence","map","Request","String","all","scheme","URL","url","protocol","responses","i","undefined","CacheStorage","opts","keys","cacheNames","reduce","chain","cacheName","module","exports"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1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AAiB,UAAC2C,UAAD,EAAgB;AACtC,UAAIlC,KAAJ;AAEA,aAAOkC,UAAU,CAACC,MAAX,CAAkB,UAACC,KAAD,EAAQC,SAAR,EAAsB;AAC7C,eAAOD,KAAK,CAAC7C,IAAN,CAAW,YAAM;AACtB,iBACES,KAAK,IACLtB,MAAM,CACHgB,IADH,CACQ2C,SADR,EAEG9C,IAFH,CAEQ,UAACI,KAAD,EAAW;AACf,mBAAOA,KAAK,CAACK,KAAN,CAAYd,OAAZ,EAAqB8C,IAArB,CAAP;AACD,WAJH,EAKGzC,IALH,CAKQ,UAACC,QAAD,EAAc;AAClBQ,iBAAK,GAAGR,QAAR;AACA,mBAAOQ,KAAP;AACD,WARH,CAFF;AAYD,SAbM,CAAP;AAcD,OAfM,EAeJc,OAAO,CAACC,OAAR,EAfI,CAAP;AAgBD,KAnBM,CAAP;AAoBD,GAvBD;AAwBD;;AAEDuB,MAAM,CAACC,OAAP,GAAiB3D,IAAI,CAACF,MAAtB,C","file":"sw.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/mnt/data/srv/dist/web/nysca/vendor/a2nt/silverstripe-progressivewebapp/client/dist\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./client/src/sw.js\");\n","// caches polyfill because it is not added to native yet!\nvar caches = require('./thirdparty/serviceworker-caches');\n\nif (typeof self.CACHE_NAME !== 'string') {\n throw new Error('Cache Name cannot be empty');\n}\n\nself.addEventListener('fetch', (event) => {\n // Clone the request for fetch and cache\n // A request is a stream and can be consumed only once.\n var fetchRequest = event.request.clone(),\n cacheRequest = event.request.clone();\n\n // Respond with content from fetch or cache\n event.respondWith(\n // Try fetch\n fetch(fetchRequest)\n // when fetch is successful, we update the cache\n .then((response) => {\n // A response is a stream and can be consumed only once.\n // Because we want the browser to consume the response,\n // as well as cache to consume the response, we need to\n // clone it so we have 2 streams\n var responseToCache = response.clone();\n\n // and update the cache\n caches.open(self.CACHE_NAME).then((cache) => {\n // Clone the request again to use it\n // as the key for our cache\n var cacheSaveRequest = event.request.clone();\n cache.put(cacheSaveRequest, responseToCache);\n });\n\n // Return the response stream to be consumed by browser\n return response;\n })\n\n // when fetch times out or fails\n .catch((err) => {\n // Return the promise which\n // resolves on a match in cache for the current request\n // or rejects if no matches are found\n return caches.match(cacheRequest);\n }),\n );\n});\n\n// Now we need to clean up resources in the previous versions\n// of Service Worker scripts\nself.addEventListener('activate', (event) => {\n // Destroy the cache\n event.waitUntil(caches.delete(self.CACHE_NAME));\n});\n","if (!Cache.prototype.add) {\n Cache.prototype.add = function add(request) {\n return this.addAll([request]);\n };\n}\n\nif (!Cache.prototype.addAll) {\n Cache.prototype.addAll = function addAll(requests) {\n var cache = this;\n\n // Since DOMExceptions are not constructable:\n function NetworkError(message) {\n this.name = 'NetworkError';\n this.code = 19;\n this.message = message;\n }\n NetworkError.prototype = Object.create(Error.prototype);\n\n return Promise.resolve()\n .then(function() {\n if (arguments.length < 1) throw new TypeError();\n\n // Simulate sequence<(Request or USVString)> binding:\n var sequence = [];\n\n requests = requests.map((request) => {\n if (request instanceof Request) {\n return request;\n } else {\n return String(request); // may throw TypeError\n }\n });\n\n return Promise.all(\n requests.map((request) => {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n\n var scheme = new URL(request.url).protocol;\n\n if (scheme !== 'http:' && scheme !== 'https:') {\n throw new NetworkError('Invalid scheme');\n }\n\n return fetch(request.clone());\n }),\n );\n })\n .then((responses) => {\n // TODO: check that requests don't overwrite one another\n // (don't think this is possible to polyfill due to opaque responses)\n return Promise.all(\n responses.map((response, i) => {\n return cache.put(requests[i], response);\n }),\n );\n })\n .then(() => {\n return undefined;\n });\n };\n}\n\nif (!CacheStorage.prototype.match) {\n // This is probably vulnerable to race conditions (removing caches etc)\n CacheStorage.prototype.match = function match(request, opts) {\n var caches = this;\n\n return this.keys().then((cacheNames) => {\n var match;\n\n return cacheNames.reduce((chain, cacheName) => {\n return chain.then(() => {\n return (\n match ||\n caches\n .open(cacheName)\n .then((cache) => {\n return cache.match(request, opts);\n })\n .then((response) => {\n match = response;\n return match;\n })\n );\n });\n }, Promise.resolve());\n });\n };\n}\n\nmodule.exports = self.caches;\n"],"sourceRoot":""}
|
7
client/src/lib/log.js
Normal file
7
client/src/lib/log.js
Normal file
@ -0,0 +1,7 @@
|
||||
const log = (msg) => {
|
||||
if (debug) {
|
||||
console.log(msg);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = log;
|
@ -1,6 +1,14 @@
|
||||
// caches polyfill because it is not added to native yet!
|
||||
var log = require('./lib/log');
|
||||
var caches = require('./thirdparty/serviceworker-caches');
|
||||
|
||||
if (debug) {
|
||||
log('SW: debug is on');
|
||||
log(`SW: CACHE_NAME: ${CACHE_NAME}`);
|
||||
log(`SW: appDomain: ${appDomain}`);
|
||||
log(`SW: lang: ${lang}`);
|
||||
}
|
||||
|
||||
if (typeof self.CACHE_NAME !== 'string') {
|
||||
throw new Error('Cache Name cannot be empty');
|
||||
}
|
||||
@ -37,6 +45,7 @@ self.addEventListener('fetch', (event) => {
|
||||
|
||||
// when fetch times out or fails
|
||||
.catch((err) => {
|
||||
log('SW: fetch failed');
|
||||
// Return the promise which
|
||||
// resolves on a match in cache for the current request
|
||||
// or rejects if no matches are found
|
||||
@ -48,6 +57,11 @@ self.addEventListener('fetch', (event) => {
|
||||
// Now we need to clean up resources in the previous versions
|
||||
// of Service Worker scripts
|
||||
self.addEventListener('activate', (event) => {
|
||||
log(`SW: activated: ${version}`);
|
||||
// Destroy the cache
|
||||
event.waitUntil(caches.delete(self.CACHE_NAME));
|
||||
});
|
||||
|
||||
self.addEventListener('install', (e) => {
|
||||
log(`SW: installing version: ${version}`);
|
||||
});
|
||||
|
@ -3,8 +3,6 @@ var version = '{$Version}',
|
||||
appDomain = '{$BaseUrl}',
|
||||
lang = 'en',
|
||||
debug = <% if $DebugMode %>true<% else %>false<% end_if %>,
|
||||
isPushEnabled = true,
|
||||
offline = false,
|
||||
CACHE_NAME = 'sw' + version;
|
||||
$Script.RAW;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
const SOURCEDIR = './src';
|
||||
const COMPRESS = false;
|
||||
const COMPRESS = true;
|
||||
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
|
Loading…
Reference in New Issue
Block a user