Socket
Socket
Sign inDemoInstall

workbox-window

Package Overview
Dependencies
1
Maintainers
4
Versions
59
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.0 to 5.1.0

2

_version.js
"use strict";
// @ts-ignore
try {
self['workbox:window:5.0.0'] && _();
self['workbox:window:5.1.0'] && _();
}
catch (e) { }

@@ -5,6 +5,6 @@ (function (global, factory) {

(global = global || self, factory(global.workbox = {}));
}(this, function (exports) { 'use strict';
}(this, (function (exports) { 'use strict';
try {
self['workbox:window:5.0.0'] && _();
self['workbox:window:5.1.0'] && _();
} catch (e) {}

@@ -69,3 +69,3 @@

try {
self['workbox:core:5.0.0'] && _();
self['workbox:core:5.1.0'] && _();
} catch (e) {}

@@ -213,5 +213,3 @@

*/
var WorkboxEventTarget =
/*#__PURE__*/
function () {
var WorkboxEventTarget = /*#__PURE__*/function () {
function WorkboxEventTarget() {

@@ -385,5 +383,3 @@ this._eventListenerRegistry = new Map();

var Workbox =
/*#__PURE__*/
function (_WorkboxEventTarget) {
var Workbox = /*#__PURE__*/function (_WorkboxEventTarget) {
_inheritsLoose(Workbox, _WorkboxEventTarget);

@@ -642,5 +638,4 @@

var _proto = Workbox.prototype;
_proto.register = _async(function (_temp) {
var _this2 = this;
_proto.register = function register(_temp) {
var _ref = _temp === void 0 ? {} : _temp,

@@ -650,103 +645,109 @@ _ref$immediate = _ref.immediate,

{
if (_this2._registrationTime) {
logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
return;
}
}
try {
var _this3 = this;
return _invoke(function () {
if (!immediate && document.readyState !== 'complete') {
return _awaitIgnored(new Promise(function (res) {
return window.addEventListener('load', res);
}));
if ("dev" !== 'production') {
if (_this3._registrationTime) {
logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
return;
}
}
}, function () {
// 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();
return _await(_this2._registerScript(), function (_this2$_registerScrip) {
_this2._registration = _this2$_registerScrip;
return _invoke(function () {
if (!immediate && document.readyState !== 'complete') {
return _awaitIgnored(new Promise(function (res) {
return window.addEventListener('load', res);
}));
}
}, function () {
// Set this flag to true if any service worker was controlling the page
// at registration time.
_this3._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.
// If we have a compatible controller, store the controller as the "own"
// SW, resolve active/controlling deferreds and add necessary listeners.
if (_this2._compatibleControllingSW) {
_this2._sw = _this2._compatibleControllingSW;
_this3._compatibleControllingSW = _this3._getControllingSWIfCompatible();
return _await(_this3._registerScript(), function (_this2$_registerScrip) {
_this3._registration = _this2$_registerScrip;
_this2._activeDeferred.resolve(_this2._compatibleControllingSW);
// If we have a compatible controller, store the controller as the "own"
// SW, resolve active/controlling deferreds and add necessary listeners.
if (_this3._compatibleControllingSW) {
_this3._sw = _this3._compatibleControllingSW;
_this2._controllingDeferred.resolve(_this2._compatibleControllingSW);
_this3._activeDeferred.resolve(_this3._compatibleControllingSW);
_this2._compatibleControllingSW.addEventListener('statechange', _this2._onStateChange, {
once: true
});
} // If there's a waiting service worker with a matching URL before the
// `updatefound` event fires, it likely means that this site is open
// in another tab, or the user refreshed the page (and thus the previous
// page wasn't fully unloaded before this page started loading).
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
_this3._controllingDeferred.resolve(_this3._compatibleControllingSW);
_this3._compatibleControllingSW.addEventListener('statechange', _this3._onStateChange, {
once: true
});
} // If there's a waiting service worker with a matching URL before the
// `updatefound` event fires, it likely means that this site is open
// in another tab, or the user refreshed the page (and thus the previous
// page wasn't fully unloaded before this page started loading).
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
var waitingSW = _this2._registration.waiting;
if (waitingSW && urlsMatch(waitingSW.scriptURL, _this2._scriptURL)) {
// Store the waiting SW as the "own" Sw, even if it means overwriting
// a compatible controller.
_this2._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
// listener after awaiting `register()` will get this event.
var waitingSW = _this3._registration.waiting;
dontWaitFor(Promise.resolve().then(function () {
_this2.dispatchEvent(new WorkboxEvent('waiting', {
sw: waitingSW,
wasWaitingBeforeRegister: true
if (waitingSW && urlsMatch(waitingSW.scriptURL, _this3._scriptURL)) {
// Store the waiting SW as the "own" Sw, even if it means overwriting
// a compatible controller.
_this3._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
// listener after awaiting `register()` will get this event.
dontWaitFor(Promise.resolve().then(function () {
_this3.dispatchEvent(new WorkboxEvent('waiting', {
sw: waitingSW,
wasWaitingBeforeRegister: true
}));
if ("dev" !== 'production') {
logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
}
}));
} // If an "own" SW is already set, resolve the deferred.
{
logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
}
}));
} // If an "own" SW is already set, resolve the deferred.
if (_this3._sw) {
_this3._swDeferred.resolve(_this3._sw);
if (_this2._sw) {
_this2._swDeferred.resolve(_this2._sw);
_this3._ownSWs.add(_this3._sw);
}
_this2._ownSWs.add(_this2._sw);
}
if ("dev" !== 'production') {
logger.log('Successfully registered service worker.', _this3._scriptURL);
{
logger.log('Successfully registered service worker.', _this2._scriptURL);
if (navigator.serviceWorker.controller) {
if (_this2._compatibleControllingSW) {
logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
} else {
logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
if (navigator.serviceWorker.controller) {
if (_this3._compatibleControllingSW) {
logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
} else {
logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
}
}
}
var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
var scopeURL = new URL(_this2._registerOptions.scope || _this2._scriptURL, document.baseURI);
var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
return !location.pathname.startsWith(scopeURLBasePath);
};
var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
var scopeURL = new URL(_this3._registerOptions.scope || _this3._scriptURL, document.baseURI);
var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
return !location.pathname.startsWith(scopeURLBasePath);
};
if (currentPageIsOutOfScope()) {
logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
if (currentPageIsOutOfScope()) {
logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
}
}
}
_this2._registration.addEventListener('updatefound', _this2._onUpdateFound);
_this3._registration.addEventListener('updatefound', _this3._onUpdateFound);
navigator.serviceWorker.addEventListener('controllerchange', _this2._onControllerChange, {
once: true
navigator.serviceWorker.addEventListener('controllerchange', _this3._onControllerChange, {
once: true
});
return _this3._registration;
});
return _this2._registration;
});
});
})
} catch (e) {
return Promise.reject(e);
}
}
/**

@@ -756,16 +757,21 @@ * Checks for updates of the registered service worker.

;
_proto.update = _async(function () {
var _this3 = this;
if (!_this3._registration) {
{
logger.error('Cannot update a Workbox instance without ' + 'being registered. Register the Workbox instance first.');
}
_proto.update = function update() {
try {
var _this5 = this;
return;
} // Try to update registration
if (!_this5._registration) {
if ("dev" !== 'production') {
logger.error('Cannot update a Workbox instance without ' + 'being registered. Register the Workbox instance first.');
}
return;
} // Try to update registration
return _awaitIgnored(_this3._registration.update());
})
return _awaitIgnored(_this5._registration.update());
} catch (e) {
return Promise.reject(e);
}
}
/**

@@ -797,9 +803,13 @@ * Resolves to the service worker registered by this instance as soon as it

*/
_proto.getSW = _async(function () {
var _this4 = this;
_proto.getSW = function getSW() {
try {
var _this7 = this;
// If `this._sw` is set, resolve with that as we want `getSW()` to
// return the correct (new) service worker if an update is found.
return _this4._sw !== undefined ? _this4._sw : _this4._swDeferred.promise;
})
// If `this._sw` is set, resolve with that as we want `getSW()` to
// return the correct (new) service worker if an update is found.
return _this7._sw !== undefined ? _this7._sw : _this7._swDeferred.promise;
} catch (e) {
return Promise.reject(e);
}
}
/**

@@ -819,9 +829,14 @@ * Sends the passed data object to the service worker registered by this

;
_proto.messageSW = _async(function (data) {
var _this5 = this;
return _await(_this5.getSW(), function (sw) {
return messageSW(sw, data);
});
})
_proto.messageSW = function messageSW$1(data) {
try {
var _this9 = this;
return _await(_this9.getSW(), function (sw) {
return messageSW(sw, data);
});
} catch (e) {
return Promise.reject(e);
}
}
/**

@@ -853,22 +868,26 @@ * Checks for a service worker already controlling the page and returns

_proto._registerScript = _async(function () {
var _this6 = this;
_proto._registerScript = function _registerScript() {
try {
var _this11 = this;
return _catch(function () {
return _await(navigator.serviceWorker.register(_this6._scriptURL, _this6._registerOptions), function (reg) {
// Keep track of when registration happened, so it can be used in the
// `this._onUpdateFound` heuristic. Also use the presence of this
// property as a way to see if `.register()` has been called.
_this6._registrationTime = performance.now();
return reg;
});
}, function (error) {
{
logger.error(error);
} // Re-throw the error.
return _catch(function () {
return _await(navigator.serviceWorker.register(_this11._scriptURL, _this11._registerOptions), function (reg) {
// Keep track of when registration happened, so it can be used in the
// `this._onUpdateFound` heuristic. Also use the presence of this
// property as a way to see if `.register()` has been called.
_this11._registrationTime = performance.now();
return reg;
});
}, function (error) {
if ("dev" !== 'production') {
logger.error(error);
} // Re-throw the error.
throw error;
});
});
throw error;
});
} catch (e) {
return Promise.reject(e);
}
};

@@ -1095,3 +1114,3 @@ _createClass(Workbox, [{

}));
})));
//# sourceMappingURL=workbox-window.dev.umd.js.map

@@ -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:5.0.0"]&&_()}catch(n){}function t(n,t){return new Promise(function(e){var r=new MessageChannel;r.port1.onmessage=function(n){e(n.data)},n.postMessage(t,[r.port2])})}function e(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}try{self["workbox:core:5.0.0"]&&_()}catch(n){}var r=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})};function i(n,t){var e=location.href;return new URL(n,e).href===new URL(t,e).href}var o=function(n,t){this.type=n,Object.assign(this,t)};function u(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}var a=200;function c(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)}}}var f=6e4;function s(){}var v=function(n){var s,v;function l(t,e){var s;return void 0===e&&(e={}),(s=n.call(this)||this).t={},s.i=0,s.o=new r,s.u=new r,s.s=new r,s.v=0,s.h=new Set,s.l=function(){var n=s.g,t=n.installing;s.i>0||!i(t.scriptURL,s.m)||performance.now()>s.v+f?(s.p=t,n.removeEventListener("updatefound",s.l)):(s.P=t,s.h.add(t),s.o.resolve(t)),++s.i,t.addEventListener("statechange",s.j)},s.j=function(n){var t=s.g,e=n.target,r=e.state,i=e===s.p,u=i?"external":"",c={sw:e,originalEvent:n};!i&&s.k&&(c.isUpdate=!0),s.dispatchEvent(new o(u+r,c)),"installed"===r?s.O=self.setTimeout(function(){"installed"===r&&t.waiting===e&&s.dispatchEvent(new o(u+"waiting",c))},a):"activating"===r&&(clearTimeout(s.O),i||s.u.resolve(e))},s._=function(n){var t=s.P;t===navigator.serviceWorker.controller&&(s.dispatchEvent(new o("controlling",{sw:t,originalEvent:n,isUpdate:s.k})),s.s.resolve(t))},s.M=c(function(n){var t=n.data,e=n.source;return u(s.getSW(),function(){s.h.has(e)&&s.dispatchEvent(new o("message",{data:t,sw:e,originalEvent:n}))})}),s.m=t,s.t=e,navigator.serviceWorker.addEventListener("message",s.M),s}v=n,(s=l).prototype=Object.create(v.prototype),s.prototype.constructor=s,s.__proto__=v;var w,d,g,m=l.prototype;return m.register=c(function(n){var t=this,e=(void 0===n?{}:n).immediate,r=void 0!==e&&e;return function(n,t){var e=n();if(e&&e.then)return e.then(t);return t(e)}(function(){if(!r&&"complete"!==document.readyState)return h(new Promise(function(n){return window.addEventListener("load",n)}))},function(){return t.k=Boolean(navigator.serviceWorker.controller),t.R=t.S(),u(t.U(),function(n){t.g=n,t.R&&(t.P=t.R,t.u.resolve(t.R),t.s.resolve(t.R),t.R.addEventListener("statechange",t.j,{once:!0}));var e=t.g.waiting;return e&&i(e.scriptURL,t.m)&&(t.P=e,Promise.resolve().then(function(){t.dispatchEvent(new o("waiting",{sw:e,wasWaitingBeforeRegister:!0}))}).then(function(){})),t.P&&(t.o.resolve(t.P),t.h.add(t.P)),t.g.addEventListener("updatefound",t.l),navigator.serviceWorker.addEventListener("controllerchange",t._,{once:!0}),t.g})})}),m.update=c(function(){if(this.g)return h(this.g.update())}),m.getSW=c(function(){return void 0!==this.P?this.P:this.o.promise}),m.messageSW=c(function(n){return u(this.getSW(),function(e){return t(e,n)})}),m.S=function(){var n=navigator.serviceWorker.controller;return n&&i(n.scriptURL,this.m)?n:void 0},m.U=c(function(){var n=this;return function(n,t){try{var e=n()}catch(n){return t(n)}if(e&&e.then)return e.then(void 0,t);return e}(function(){return u(navigator.serviceWorker.register(n.m,n.t),function(t){return n.v=performance.now(),t})},function(n){throw n})}),w=l,(d=[{key:"active",get:function(){return this.u.promise}},{key:"controlling",get:function(){return this.s.promise}}])&&e(w.prototype,d),g&&e(w,g),l}(function(){function n(){this.B=new Map}var t=n.prototype;return t.addEventListener=function(n,t){this.L(n).add(t)},t.removeEventListener=function(n,t){this.L(n).delete(t)},t.dispatchEvent=function(n){n.target=this;var t=this.L(n.type),e=Array.isArray(t),r=0;for(t=e?t:t[Symbol.iterator]();;){var i;if(e){if(r>=t.length)break;i=t[r++]}else{if((r=t.next()).done)break;i=r.value}i(n)}},t.L=function(n){return this.B.has(n)||this.B.set(n,new Set),this.B.get(n)},n}());function h(n,t){if(!t)return n&&n.then?n.then(s):Promise.resolve()}n.Workbox=v,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:5.1.0"]&&_()}catch(n){}function t(n,t){return new Promise((function(r){var e=new MessageChannel;e.port1.onmessage=function(n){r(n.data)},n.postMessage(t,[e.port2])}))}function r(n,t){for(var r=0;r<t.length;r++){var e=t[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}try{self["workbox:core:5.1.0"]&&_()}catch(n){}var e=function(){var n=this;this.promise=new Promise((function(t,r){n.resolve=t,n.reject=r}))};function i(n,t){var r=location.href;return new URL(n,r).href===new URL(t,r).href}var o=function(n,t){this.type=n,Object.assign(this,t)};function u(n,t,r){return r?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function c(){}var a=function(n){var c,a;function s(t,r){var c,a;return void 0===r&&(r={}),(c=n.call(this)||this).t={},c.i=0,c.o=new e,c.u=new e,c.s=new e,c.v=0,c.h=new Set,c.l=function(){var n=c.g,t=n.installing;c.i>0||!i(t.scriptURL,c.m)||performance.now()>c.v+6e4?(c.p=t,n.removeEventListener("updatefound",c.l)):(c.P=t,c.h.add(t),c.o.resolve(t)),++c.i,t.addEventListener("statechange",c.j)},c.j=function(n){var t=c.g,r=n.target,e=r.state,i=r===c.p,u=i?"external":"",a={sw:r,originalEvent:n};!i&&c.k&&(a.isUpdate=!0),c.dispatchEvent(new o(u+e,a)),"installed"===e?c.O=self.setTimeout((function(){"installed"===e&&t.waiting===r&&c.dispatchEvent(new o(u+"waiting",a))}),200):"activating"===e&&(clearTimeout(c.O),i||c.u.resolve(r))},c._=function(n){var t=c.P;t===navigator.serviceWorker.controller&&(c.dispatchEvent(new o("controlling",{sw:t,originalEvent:n,isUpdate:c.k})),c.s.resolve(t))},c.M=(a=function(n){var t=n.data,r=n.source;return u(c.getSW(),(function(){c.h.has(r)&&c.dispatchEvent(new o("message",{data:t,sw:r,originalEvent:n}))}))},function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];try{return Promise.resolve(a.apply(this,n))}catch(n){return Promise.reject(n)}}),c.m=t,c.t=r,navigator.serviceWorker.addEventListener("message",c.M),c}a=n,(c=s).prototype=Object.create(a.prototype),c.prototype.constructor=c,c.__proto__=a;var v,h,l,w=s.prototype;return w.register=function(n){var t=(void 0===n?{}:n).immediate,r=void 0!==t&&t;try{var e=this;return function(n,t){var r=n();if(r&&r.then)return r.then(t);return t(r)}((function(){if(!r&&"complete"!==document.readyState)return f(new Promise((function(n){return window.addEventListener("load",n)})))}),(function(){return e.k=Boolean(navigator.serviceWorker.controller),e.R=e.S(),u(e.U(),(function(n){e.g=n,e.R&&(e.P=e.R,e.u.resolve(e.R),e.s.resolve(e.R),e.R.addEventListener("statechange",e.j,{once:!0}));var t=e.g.waiting;return t&&i(t.scriptURL,e.m)&&(e.P=t,Promise.resolve().then((function(){e.dispatchEvent(new o("waiting",{sw:t,wasWaitingBeforeRegister:!0}))})).then((function(){}))),e.P&&(e.o.resolve(e.P),e.h.add(e.P)),e.g.addEventListener("updatefound",e.l),navigator.serviceWorker.addEventListener("controllerchange",e._,{once:!0}),e.g}))}))}catch(n){return Promise.reject(n)}},w.update=function(){try{return this.g?f(this.g.update()):void 0}catch(n){return Promise.reject(n)}},w.getSW=function(){try{return void 0!==this.P?this.P:this.o.promise}catch(n){return Promise.reject(n)}},w.messageSW=function(n){try{return u(this.getSW(),(function(r){return t(r,n)}))}catch(n){return Promise.reject(n)}},w.S=function(){var n=navigator.serviceWorker.controller;return n&&i(n.scriptURL,this.m)?n:void 0},w.U=function(){try{var n=this;return function(n,t){try{var r=n()}catch(n){return t(n)}if(r&&r.then)return r.then(void 0,t);return r}((function(){return u(navigator.serviceWorker.register(n.m,n.t),(function(t){return n.v=performance.now(),t}))}),(function(n){throw n}))}catch(n){return Promise.reject(n)}},v=s,(h=[{key:"active",get:function(){return this.u.promise}},{key:"controlling",get:function(){return this.s.promise}}])&&r(v.prototype,h),l&&r(v,l),s}(function(){function n(){this.B=new Map}var t=n.prototype;return t.addEventListener=function(n,t){this.L(n).add(t)},t.removeEventListener=function(n,t){this.L(n).delete(t)},t.dispatchEvent=function(n){n.target=this;var t=this.L(n.type),r=Array.isArray(t),e=0;for(t=r?t:t[Symbol.iterator]();;){var i;if(r){if(e>=t.length)break;i=t[e++]}else{if((e=t.next()).done)break;i=e.value}i(n)}},t.L=function(n){return this.B.has(n)||this.B.set(n,new Set),this.B.get(n)},n}());function f(n,t){if(!t)return n&&n.then?n.then(c):Promise.resolve()}n.Workbox=a,n.messageSW=t,Object.defineProperty(n,"__esModule",{value:!0})}));
//# sourceMappingURL=workbox-window.prod.umd.js.map

@@ -25,3 +25,3 @@ /*

return new Promise((resolve) => {
let messageChannel = new MessageChannel();
const messageChannel = new MessageChannel();
messageChannel.port1.onmessage = (event) => {

@@ -33,3 +33,2 @@ resolve(event.data);

}
;
export { messageSW };
{
"name": "workbox-window",
"version": "5.0.0",
"version": "5.1.0",
"license": "MIT",

@@ -32,5 +32,5 @@ "author": "Google's Web DevRel Team",

"dependencies": {
"workbox-core": "^5.0.0"
"workbox-core": "^5.1.0"
},
"gitHead": "571ffded1872309a305f108a99a5a36982fde342"
"gitHead": "2a6b84b892b5c404671b898e926bf37b65d261da"
}
// @ts-ignore
try{self['workbox:window:5.0.0']&&_()}catch(e){}
try{self['workbox:window:5.1.0']&&_()}catch(e){}

@@ -28,3 +28,3 @@ /*

return new Promise((resolve) => {
let messageChannel = new MessageChannel();
const messageChannel = new MessageChannel();
messageChannel.port1.onmessage = (event: MessageEvent) => {

@@ -35,4 +35,4 @@ resolve(event.data);

});
};
}
export {messageSW}

@@ -24,2 +24,2 @@ /*

return new URL(url1, href).href === new URL(url2, href).href;
};
}

@@ -21,3 +21,3 @@ /*

export class WorkboxEventTarget {
private _eventListenerRegistry: Map<keyof WorkboxEventMap, Set<ListenerCallback>> = new Map();
private readonly _eventListenerRegistry: Map<keyof WorkboxEventMap, Set<ListenerCallback>> = new Map();

@@ -24,0 +24,0 @@ /**

@@ -46,10 +46,10 @@ /*

class Workbox extends WorkboxEventTarget {
private _scriptURL: string;
private _registerOptions: RegistrationOptions = {};
private _updateFoundCount: number = 0;
private readonly _scriptURL: string;
private readonly _registerOptions: RegistrationOptions = {};
private _updateFoundCount = 0;
// Deferreds we can resolve later.
private _swDeferred: Deferred<ServiceWorker> = new Deferred();
private _activeDeferred: Deferred<ServiceWorker> = new Deferred();
private _controllingDeferred: Deferred<ServiceWorker> = new Deferred();
private readonly _swDeferred: Deferred<ServiceWorker> = new Deferred();
private readonly _activeDeferred: Deferred<ServiceWorker> = new Deferred();
private readonly _controllingDeferred: Deferred<ServiceWorker> = new Deferred();

@@ -61,3 +61,3 @@ private _registrationTime: DOMHighResTimeStamp = 0;

private _sw?: ServiceWorker;
private _ownSWs: Set<ServiceWorker> = new Set();
private readonly _ownSWs: Set<ServiceWorker> = new Set();
private _externalSW?: ServiceWorker;

@@ -127,4 +127,4 @@ private _waitingTimeout?: number;

this._sw = this._compatibleControllingSW;
this._activeDeferred.resolve!(this._compatibleControllingSW);
this._controllingDeferred.resolve!(this._compatibleControllingSW);
this._activeDeferred.resolve(this._compatibleControllingSW);
this._controllingDeferred.resolve(this._compatibleControllingSW);

@@ -162,3 +162,3 @@ this._compatibleControllingSW.addEventListener(

if (this._sw) {
this._swDeferred.resolve!(this._sw);
this._swDeferred.resolve(this._sw);
this._ownSWs.add(this._sw);

@@ -329,6 +329,6 @@ }

*/
private _onUpdateFound = () => {
private readonly _onUpdateFound = () => {
// `this._registration` will never be `undefined` after an update is found.
const registration = this._registration!;
const installingSW = <ServiceWorker> registration.installing;
const installingSW = registration.installing as ServiceWorker;

@@ -347,3 +347,3 @@ // If the script URL passed to `navigator.serviceWorker.register()` is

// To minimize the possibility of a false positive, we use the logic here:
let updateLikelyTriggeredExternally =
const updateLikelyTriggeredExternally =
// Since we enforce only calling `register()` once, and since we don't

@@ -375,3 +375,3 @@ // add the `updatefound` event listener until the `register()` call, if

this._ownSWs.add(installingSW);
this._swDeferred.resolve!(installingSW);
this._swDeferred.resolve(installingSW);

@@ -402,3 +402,3 @@ // The `installing` state isn't something we have a dedicated

*/
private _onStateChange = (originalEvent: Event) => {
private readonly _onStateChange = (originalEvent: Event) => {
// `this._registration` will never be `undefined` after an update is found.

@@ -411,3 +411,3 @@ const registration = this._registration!;

const eventProps: {sw: ServiceWorker, originalEvent: Event, isUpdate?: boolean} = {
const eventProps: {sw: ServiceWorker; originalEvent: Event; isUpdate?: boolean} = {
sw,

@@ -452,3 +452,3 @@ originalEvent

if (!isExternal) {
this._activeDeferred.resolve!(sw);
this._activeDeferred.resolve(sw);
}

@@ -494,3 +494,3 @@ }

*/
private _onControllerChange = (originalEvent: Event) => {
private readonly _onControllerChange = (originalEvent: Event) => {
const sw = this._sw;

@@ -507,3 +507,3 @@ if (sw === navigator.serviceWorker.controller) {

}
this._controllingDeferred.resolve!(sw);
this._controllingDeferred.resolve(sw);
}

@@ -516,3 +516,3 @@ }

*/
private _onMessage = async (originalEvent: MessageEvent) => {
private readonly _onMessage = async (originalEvent: MessageEvent) => {
const {data, source} = originalEvent;

@@ -519,0 +519,0 @@

@@ -22,2 +22,1 @@ /*

}
;

@@ -10,3 +10,3 @@ import { WorkboxEvent, WorkboxEventMap } from './WorkboxEvent.js';

export declare class WorkboxEventTarget {
private _eventListenerRegistry;
private readonly _eventListenerRegistry;
/**

@@ -13,0 +13,0 @@ * @param {string} type

@@ -19,8 +19,8 @@ import { WorkboxEventTarget } from './utils/WorkboxEventTarget.js';

declare class Workbox extends WorkboxEventTarget {
private _scriptURL;
private _registerOptions;
private readonly _scriptURL;
private readonly _registerOptions;
private _updateFoundCount;
private _swDeferred;
private _activeDeferred;
private _controllingDeferred;
private readonly _swDeferred;
private readonly _activeDeferred;
private readonly _controllingDeferred;
private _registrationTime;

@@ -31,3 +31,3 @@ private _isUpdate?;

private _sw?;
private _ownSWs;
private readonly _ownSWs;
private _externalSW?;

@@ -73,3 +73,3 @@ private _waitingTimeout?;

*/
readonly active: Promise<ServiceWorker>;
get active(): Promise<ServiceWorker>;
/**

@@ -87,3 +87,3 @@ * Resolves to the service worker registered by this instance as soon as it

*/
readonly controlling: Promise<ServiceWorker>;
get controlling(): Promise<ServiceWorker>;
/**

@@ -137,3 +137,3 @@ * Resolves with a reference to a service worker that matches the script URL

*/
private _onUpdateFound;
private readonly _onUpdateFound;
/**

@@ -143,3 +143,3 @@ * @private

*/
private _onStateChange;
private readonly _onStateChange;
/**

@@ -149,3 +149,3 @@ * @private

*/
private _onControllerChange;
private readonly _onControllerChange;
/**

@@ -155,3 +155,3 @@ * @private

*/
private _onMessage;
private readonly _onMessage;
}

@@ -158,0 +158,0 @@ export { Workbox };

@@ -79,3 +79,3 @@ /*

// To minimize the possibility of a false positive, we use the logic here:
let updateLikelyTriggeredExternally =
const updateLikelyTriggeredExternally =
// Since we enforce only calling `register()` once, and since we don't

@@ -82,0 +82,0 @@ // add the `updatefound` event listener until the `register()` call, if

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc