workbox-window
Advanced tools
Comparing version 4.0.0-rc.2 to 4.0.0-rc.3
@@ -8,3 +8,3 @@ (function (global, factory) { | ||
try { | ||
self['workbox:window:4.0.0-rc.2'] && _(); | ||
self['workbox:window:4.0.0-rc.3'] && _(); | ||
} catch (e) {} // eslint-disable-line | ||
@@ -78,3 +78,3 @@ | ||
try { | ||
self['workbox:core:4.0.0-rc.2'] && _(); | ||
self['workbox:core:4.0.0-rc.3'] && _(); | ||
} catch (e) {} // eslint-disable-line | ||
@@ -373,2 +373,12 @@ | ||
* | ||
* @fires [message]{@link module:workbox-window.Workbox#message} | ||
* @fires [installed]{@link module:workbox-window.Workbox#installed} | ||
* @fires [waiting]{@link module:workbox-window.Workbox#waiting} | ||
* @fires [controlling]{@link module:workbox-window.Workbox#controlling} | ||
* @fires [activated]{@link module:workbox-window.Workbox#activated} | ||
* @fires [redundant]{@link module:workbox-window.Workbox#redundant} | ||
* @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled} | ||
* @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting} | ||
* @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated} | ||
* | ||
* @memberof module:workbox-window | ||
@@ -449,5 +459,8 @@ */ | ||
}, function () { | ||
// Before registering, attempt to determine if a SW is already controlling | ||
// Set this flag to true if any service worker was controlling the page | ||
// at registration time. | ||
_this2._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling | ||
// the page, and if that SW script (and version, if specified) matches this | ||
// instance's script. | ||
_this2._compatibleControllingSW = _this2._getControllingSWIfCompatible(); | ||
@@ -472,2 +485,22 @@ return _await(_this2._registerScript(), function (_this2$_registerScrip) { | ||
}); | ||
} // If there's a waiting service worker with a matching URL before the | ||
// `updatefound` event fires, it likely means the this site is open | ||
// in another tab, or the user refreshed the page without unloading it | ||
// first. | ||
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting | ||
if (_this2._registration.waiting && urlsMatch(_this2._registration.waiting.scriptURL, _this2._scriptURL)) { | ||
// Run this in the next microtask, so any code that adds an event | ||
// listener after awaiting `register()` will get this event. | ||
Promise.resolve().then(function () { | ||
_this2.dispatchEvent(new WorkboxEvent('waiting', { | ||
sw: _this2._registration.waiting, | ||
wasWaitingBeforeRegister: true | ||
})); | ||
{ | ||
logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...'); | ||
} | ||
}); | ||
} | ||
@@ -484,9 +517,2 @@ | ||
} | ||
} // If there's an active and waiting service worker before the | ||
// `updatefound` event fires, it means there was a waiting service worker | ||
// in the queue before this one was registered. | ||
if (_this2._registration.waiting && _this2._registration.active) { | ||
logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...'); | ||
} | ||
@@ -715,7 +741,13 @@ | ||
var eventPrefix = isExternal ? 'external' : ''; | ||
this.dispatchEvent(new WorkboxEvent(eventPrefix + state, { | ||
var eventProps = { | ||
sw: sw, | ||
originalEvent: originalEvent | ||
})); | ||
}; | ||
if (!isExternal && this._isUpdate) { | ||
eventProps.isUpdate = true; | ||
} | ||
this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps)); | ||
if (state === 'installed') { | ||
@@ -733,6 +765,3 @@ // This timeout is used to ignore cases where the service worker calls | ||
if (state === 'installed' && _this6._registration.waiting === sw) { | ||
_this6.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', { | ||
sw: sw, | ||
originalEvent: originalEvent | ||
})); | ||
_this6.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps)); | ||
@@ -743,3 +772,3 @@ { | ||
} else { | ||
logger.warn('The service worker has installed but is waiting ' + ' for existing clients to close before activating...'); | ||
logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...'); | ||
} | ||
@@ -800,6 +829,2 @@ } | ||
if (sw === navigator.serviceWorker.controller) { | ||
{ | ||
logger.log('Registered service worker now controlling this page.'); | ||
} | ||
this.dispatchEvent(new WorkboxEvent('controlling', { | ||
@@ -810,2 +835,6 @@ sw: sw, | ||
{ | ||
logger.log('Registered service worker now controlling this page.'); | ||
} | ||
this._controllingDeferred.resolve(sw); | ||
@@ -854,3 +883,3 @@ } | ||
return Workbox; | ||
}(EventTargetShim); | ||
}(EventTargetShim); // The jsdoc comments below outline the events this instance may dispatch: | ||
@@ -857,0 +886,0 @@ /* |
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).workbox={})}(this,function(n){"use strict";try{self["workbox:window:4.0.0-rc.2"]&&_()}catch(n){}var t=function(n,t){return new Promise(function(e){var i=new MessageChannel;i.port1.onmessage=function(n){return e(n.data)},n.postMessage(t,[i.port2])})};function e(n,t){for(var e=0;e<t.length;e++){var i=t[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}function i(n){if(void 0===n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}try{self["workbox:core:4.0.0-rc.2"]&&_()}catch(n){}var r=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})},o=function(n,t){return new URL(n,location).href===new URL(t,location).href},u=function(n,t){Object.assign(this,t,{type:n})};function s(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function c(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function a(){}var f=function(n){var f,h;function v(t,e){var o;return void 0===e&&(e={}),(o=n.call(this)||this).t=t,o.i=e,o.o=0,o.u=new r,o.s=new r,o.h=new r,o.v=o.v.bind(i(i(o))),o.l=o.l.bind(i(i(o))),o.g=o.g.bind(i(i(o))),o.m=o.m.bind(i(i(o))),o}h=n,(f=v).prototype=Object.create(h.prototype),f.prototype.constructor=f,f.__proto__=h;var l,d,w,g=v.prototype;return g.register=s(function(n){var t,e,i=this,r=(void 0===n?{}:n).immediate,o=void 0!==r&&r;return t=function(){return i.p=i.P(),c(i.j(),function(n){return i.O=n,i.p&&(i._=i.p,i.u.resolve(i.p),i.s.resolve(i.p),i.h.resolve(i.p),i.k(i.p),i.p.addEventListener("statechange",i.l,{once:!0})),i.O.addEventListener("updatefound",i.g),navigator.serviceWorker.addEventListener("controllerchange",i.m,{once:!0}),"BroadcastChannel"in self&&(i.C=new BroadcastChannel("workbox"),i.C.addEventListener("message",i.v)),navigator.serviceWorker.addEventListener("message",i.v),i.O})},(e=function(){if(!o&&"complete"!==document.readyState)return function(n,t){if(!t)return n&&n.then?n.then(a):Promise.resolve()}(new Promise(function(n){return addEventListener("load",n)}))}())&&e.then?e.then(t):t(e)}),g.getSW=s(function(){return this.u.promise}),g.messageSW=s(function(n){return c(this.getSW(),function(t){return new Promise(function(e){var i=new MessageChannel;i.port1.onmessage=function(n){return e(n.data)},t.postMessage(n,[i.port2])})})}),g.P=function(){var n=navigator.serviceWorker.controller;if(n&&o(n.scriptURL,this.t))return n},g.j=s(function(){var n=this;return function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}(function(){return c(navigator.serviceWorker.register(n.t,n.i),function(t){return n.R=performance.now(),t})},function(n){throw n})}),g.k=function(n){t(n,{type:"WINDOW_READY",meta:"workbox-window"})},g.g=function(){var n=this.O.installing;this.o>0||!o(n.scriptURL,this.t)||performance.now()>this.R+6e4?(this.L=n,this.O.removeEventListener("updatefound",this.g)):(this._=n,this.u.resolve(n)),++this.o,n.addEventListener("statechange",this.l)},g.l=function(n){var t=this,e=n.target,i=e.state,r=e===this.L,o=r?"external":"";this.dispatchEvent(new u(o+i,{sw:e,originalEvent:n})),"installed"===i?this.M=setTimeout(function(){"installed"===i&&t.O.waiting===e&&t.dispatchEvent(new u(o+"waiting",{sw:e,originalEvent:n}))},200):"activating"===i&&(clearTimeout(this.M),r||this.s.resolve(e))},g.m=function(n){var t=this._;t===navigator.serviceWorker.controller&&(this.dispatchEvent(new u("controlling",{sw:t,originalEvent:n})),this.h.resolve(t))},g.v=function(n){var t=n.data;this.dispatchEvent(new u("message",{data:t,originalEvent:n}))},l=v,(d=[{key:"active",get:function(){return this.s.promise}},{key:"controlling",get:function(){return this.h.promise}}])&&e(l.prototype,d),w&&e(l,w),v}(function(){function n(){this.B={}}var t=n.prototype;return t.addEventListener=function(n,t){this.D(n).add(t)},t.removeEventListener=function(n,t){this.D(n).remove(t)},t.dispatchEvent=function(n){n.target=this,this.D(n.type).forEach(function(t){return t(n)})},t.D=function(n){return this.B[n]=this.B[n]||new Set},n}());n.Workbox=f,n.messageSW=t,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).workbox={})}(this,function(n){"use strict";try{self["workbox:window:4.0.0-rc.3"]&&_()}catch(n){}var t=function(n,t){return new Promise(function(e){var i=new MessageChannel;i.port1.onmessage=function(n){return e(n.data)},n.postMessage(t,[i.port2])})};function e(n,t){for(var e=0;e<t.length;e++){var i=t[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}function i(n){if(void 0===n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}try{self["workbox:core:4.0.0-rc.3"]&&_()}catch(n){}var r=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})},o=function(n,t){return new URL(n,location).href===new URL(t,location).href},u=function(n,t){Object.assign(this,t,{type:n})};function s(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function a(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function c(){}var f=function(n){var f,h;function v(t,e){var o;return void 0===e&&(e={}),(o=n.call(this)||this).t=t,o.i=e,o.o=0,o.u=new r,o.s=new r,o.h=new r,o.v=o.v.bind(i(i(o))),o.l=o.l.bind(i(i(o))),o.g=o.g.bind(i(i(o))),o.m=o.m.bind(i(i(o))),o}h=n,(f=v).prototype=Object.create(h.prototype),f.prototype.constructor=f,f.__proto__=h;var l,w,d,g=v.prototype;return g.register=s(function(n){var t,e,i=this,r=(void 0===n?{}:n).immediate,s=void 0!==r&&r;return t=function(){return i.p=Boolean(navigator.serviceWorker.controller),i.P=i.j(),a(i.O(),function(n){return i.R=n,i.P&&(i._=i.P,i.u.resolve(i.P),i.s.resolve(i.P),i.h.resolve(i.P),i.k(i.P),i.P.addEventListener("statechange",i.l,{once:!0})),i.R.waiting&&o(i.R.waiting.scriptURL,i.t)&&Promise.resolve().then(function(){i.dispatchEvent(new u("waiting",{sw:i.R.waiting,wasWaitingBeforeRegister:!0}))}),i.R.addEventListener("updatefound",i.g),navigator.serviceWorker.addEventListener("controllerchange",i.m,{once:!0}),"BroadcastChannel"in self&&(i.B=new BroadcastChannel("workbox"),i.B.addEventListener("message",i.v)),navigator.serviceWorker.addEventListener("message",i.v),i.R})},(e=function(){if(!s&&"complete"!==document.readyState)return function(n,t){if(!t)return n&&n.then?n.then(c):Promise.resolve()}(new Promise(function(n){return addEventListener("load",n)}))}())&&e.then?e.then(t):t(e)}),g.getSW=s(function(){return this.u.promise}),g.messageSW=s(function(n){return a(this.getSW(),function(t){return new Promise(function(e){var i=new MessageChannel;i.port1.onmessage=function(n){return e(n.data)},t.postMessage(n,[i.port2])})})}),g.j=function(){var n=navigator.serviceWorker.controller;if(n&&o(n.scriptURL,this.t))return n},g.O=s(function(){var n=this;return function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}(function(){return a(navigator.serviceWorker.register(n.t,n.i),function(t){return n.C=performance.now(),t})},function(n){throw n})}),g.k=function(n){t(n,{type:"WINDOW_READY",meta:"workbox-window"})},g.g=function(){var n=this.R.installing;this.o>0||!o(n.scriptURL,this.t)||performance.now()>this.C+6e4?(this.L=n,this.R.removeEventListener("updatefound",this.g)):(this._=n,this.u.resolve(n)),++this.o,n.addEventListener("statechange",this.l)},g.l=function(n){var t=this,e=n.target,i=e.state,r=e===this.L,o=r?"external":"",s={sw:e,originalEvent:n};!r&&this.p&&(s.isUpdate=!0),this.dispatchEvent(new u(o+i,s)),"installed"===i?this.M=setTimeout(function(){"installed"===i&&t.R.waiting===e&&t.dispatchEvent(new u(o+"waiting",s))},200):"activating"===i&&(clearTimeout(this.M),r||this.s.resolve(e))},g.m=function(n){var t=this._;t===navigator.serviceWorker.controller&&(this.dispatchEvent(new u("controlling",{sw:t,originalEvent:n})),this.h.resolve(t))},g.v=function(n){var t=n.data;this.dispatchEvent(new u("message",{data:t,originalEvent:n}))},l=v,(w=[{key:"active",get:function(){return this.s.promise}},{key:"controlling",get:function(){return this.h.promise}}])&&e(l.prototype,w),d&&e(l,d),v}(function(){function n(){this.W={}}var t=n.prototype;return t.addEventListener=function(n,t){this.D(n).add(t)},t.removeEventListener=function(n,t){this.D(n).remove(t)},t.dispatchEvent=function(n){n.target=this,this.D(n.type).forEach(function(t){return t(n)})},t.D=function(n){return this.W[n]=this.W[n]||new Set},n}());n.Workbox=f,n.messageSW=t,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=workbox-window.prod.umd.js.map |
{ | ||
"name": "workbox-window", | ||
"version": "4.0.0-rc.2", | ||
"version": "4.0.0-rc.3", | ||
"license": "MIT", | ||
@@ -31,5 +31,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^4.0.0-rc.2" | ||
"workbox-core": "^4.0.0-rc.3" | ||
}, | ||
"gitHead": "36439d00d488159fd552b6e805bd4cb1be827ece" | ||
"gitHead": "6cf9c94ff17beea2b211e91d4a96c22c8611d3b4" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
379798
7
2849
9
Updatedworkbox-core@^4.0.0-rc.3