Socket
Socket
Sign inDemoInstall

workbox-broadcast-update

Package Overview
Dependencies
Maintainers
3
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-broadcast-update - npm Package Compare versions

Comparing version 5.0.0-beta.0 to 5.0.0-beta.1

2

_version.js
// @ts-ignore
try {
self['workbox:broadcast-update:5.0.0-beta.0'] && _();
self['workbox:broadcast-update:5.0.0-beta.1'] && _();
}
catch (e) { }

@@ -9,2 +9,4 @@ /*

import { assert } from 'workbox-core/_private/assert.js';
import { timeout } from 'workbox-core/_private/timeout.js';
import { resultingClientExists } from 'workbox-core/_private/resultingClientExists.js';
import { logger } from 'workbox-core/_private/logger.js';

@@ -14,2 +16,6 @@ import { responsesAreSame } from './responsesAreSame.js';

import './_version.js';
// UA-sniff Safari: https://stackoverflow.com/questions/7944460/detect-safari-browser
// TODO(philipwalton): remove once this Safari bug fix has been released.
// https://bugs.webkit.org/show_bug.cgi?id=201169
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
/**

@@ -119,2 +125,20 @@ * Generates the default payload used in update messages. By default the

};
// For navigation requests, wait until the new window client exists
// before sending the message
if (options.request.mode === 'navigate') {
const resultingClientId = options.event && options.event.resultingClientId;
const resultingWin = await resultingClientExists(resultingClientId);
// Safari does not currently implement postMessage buffering and
// there's no good way to feature detect that, so to increase the
// chances of the message being delivered in Safari, we add a timeout.
// We also do this if `resultingClientExists()` didn't return a client,
// which means it timed out, so it's worth waiting a bit longer.
if (!resultingWin || isSafari) {
// 3500 is chosen because (according to CrUX data) 80% of mobile
// websites hit the DOMContentLoaded event in less than 3.5 seconds.
// And presumably sites implementing service worker are on the
// higher end of the performance spectrum.
await timeout(3500);
}
}
const windows = await self.clients.matchAll({ type: 'window' });

@@ -121,0 +145,0 @@ for (const win of windows) {

this.workbox = this.workbox || {};
this.workbox.broadcastUpdate = (function (exports, assert_js, logger_js, WorkboxError_js) {
this.workbox.broadcastUpdate = (function (exports, assert_js, timeout_js, resultingClientExists_js, logger_js, WorkboxError_js) {
'use strict';

@@ -7,3 +7,3 @@

try {
self['workbox:broadcast-update:5.0.0-beta.0'] && _();
self['workbox:broadcast-update:5.0.0-beta.1'] && _();
} catch (e) {}

@@ -78,2 +78,6 @@

*/
// TODO(philipwalton): remove once this Safari bug fix has been released.
// https://bugs.webkit.org/show_bug.cgi?id=201169
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
/**

@@ -193,3 +197,22 @@ * Generates the default payload used in update messages. By default the

payload: this._generatePayload(options)
};
}; // For navigation requests, wait until the new window client exists
// before sending the message
if (options.request.mode === 'navigate') {
const resultingClientId = options.event && options.event.resultingClientId;
const resultingWin = await resultingClientExists_js.resultingClientExists(resultingClientId); // Safari does not currently implement postMessage buffering and
// there's no good way to feature detect that, so to increase the
// chances of the message being delivered in Safari, we add a timeout.
// We also do this if `resultingClientExists()` didn't return a client,
// which means it timed out, so it's worth waiting a bit longer.
if (!resultingWin || isSafari) {
// 3500 is chosen because (according to CrUX data) 80% of mobile
// websites hit the DOMContentLoaded event in less than 3.5 seconds.
// And presumably sites implementing service worker are on the
// higher end of the performance spectrum.
await timeout_js.timeout(3500);
}
}
const windows = await self.clients.matchAll({

@@ -264,3 +287,3 @@ type: 'window'

}({}, workbox.core._private, workbox.core._private, workbox.core._private));
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
//# sourceMappingURL=workbox-broadcast-update.dev.js.map

@@ -1,2 +0,2 @@

this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(t){"use strict";try{self["workbox:broadcast-update:5.0.0-beta.0"]&&_()}catch(t){}const s=(t,s,e)=>{return!e.some(e=>t.headers.has(e)&&s.headers.has(e))||e.every(e=>{const a=t.headers.has(e)===s.headers.has(e),n=t.headers.get(e)===s.headers.get(e);return a&&n})},e="CACHE_UPDATED",a="workbox-broadcast-update",n=["content-length","etag","last-modified"];function c(t){return{cacheName:t.cacheName,updatedURL:t.request.url}}class o{constructor({headersToCheck:t,generatePayload:s}={}){this.t=t||n,this.s=s||c}async notifyIfUpdated(t){if(t.oldResponse&&!s(t.oldResponse,t.newResponse,this.t)){const s={type:e,meta:a,payload:this.s(t)},n=await self.clients.matchAll({type:"window"});for(const t of n)t.postMessage(s)}}}return t.BroadcastCacheUpdate=o,t.BroadcastUpdatePlugin=class{constructor(t){this.cacheDidUpdate=(async t=>{this.o.notifyIfUpdated(t)}),this.o=new o(t)}},t.responsesAreSame=s,t}({});
this.workbox=this.workbox||{},this.workbox.broadcastUpdate=function(t,a,s){"use strict";try{self["workbox:broadcast-update:5.0.0-beta.1"]&&_()}catch(t){}const o=(t,a,s)=>{return!s.some(s=>t.headers.has(s)&&a.headers.has(s))||s.every(s=>{const o=t.headers.has(s)===a.headers.has(s),e=t.headers.get(s)===a.headers.get(s);return o&&e})},e="CACHE_UPDATED",n="workbox-broadcast-update",i=["content-length","etag","last-modified"],c=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);function r(t){return{cacheName:t.cacheName,updatedURL:t.request.url}}class h{constructor({headersToCheck:t,generatePayload:a}={}){this.t=t||i,this.s=a||r}async notifyIfUpdated(t){if(t.oldResponse&&!o(t.oldResponse,t.newResponse,this.t)){const o={type:e,meta:n,payload:this.s(t)};if("navigate"===t.request.mode){const o=t.event&&t.event.resultingClientId;await s.resultingClientExists(o)&&!c||await a.timeout(3500)}const i=await self.clients.matchAll({type:"window"});for(const t of i)t.postMessage(o)}}}return t.BroadcastCacheUpdate=h,t.BroadcastUpdatePlugin=class{constructor(t){this.cacheDidUpdate=(async t=>{this.o.notifyIfUpdated(t)}),this.o=new h(t)}},t.responsesAreSame=o,t}({},workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-broadcast-update.prod.js.map
{
"name": "workbox-broadcast-update",
"version": "5.0.0-beta.0",
"version": "5.0.0-beta.1",
"license": "MIT",

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

"dependencies": {
"workbox-core": "^5.0.0-beta.0"
"workbox-core": "^5.0.0-beta.1"
},
"gitHead": "136b38f2c701bd7c04e808d19961310a9ede524b"
"gitHead": "01a9e9be8291f0a592891c8e2eb8d2dd09b93caf"
}
// @ts-ignore
try{self['workbox:broadcast-update:5.0.0-beta.0']&&_()}catch(e){}
try{self['workbox:broadcast-update:5.0.0-beta.1']&&_()}catch(e){}

@@ -10,2 +10,4 @@ /*

import {assert} from 'workbox-core/_private/assert.js';
import {timeout} from 'workbox-core/_private/timeout.js';
import {resultingClientExists} from 'workbox-core/_private/resultingClientExists.js';
import {CacheDidUpdateCallbackParam} from 'workbox-core/types.js';

@@ -19,2 +21,8 @@ import {logger} from 'workbox-core/_private/logger.js';

// UA-sniff Safari: https://stackoverflow.com/questions/7944460/detect-safari-browser
// TODO(philipwalton): remove once this Safari bug fix has been released.
// https://bugs.webkit.org/show_bug.cgi?id=201169
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
// Give TypeScript the correct global.

@@ -145,2 +153,24 @@ declare var self: ServiceWorkerGlobalScope;

// For navigation requests, wait until the new window client exists
// before sending the message
if (options.request.mode === 'navigate') {
const resultingClientId =
options.event && options.event.resultingClientId;
const resultingWin = await resultingClientExists(resultingClientId);
// Safari does not currently implement postMessage buffering and
// there's no good way to feature detect that, so to increase the
// chances of the message being delivered in Safari, we add a timeout.
// We also do this if `resultingClientExists()` didn't return a client,
// which means it timed out, so it's worth waiting a bit longer.
if (!resultingWin || isSafari) {
// 3500 is chosen because (according to CrUX data) 80% of mobile
// websites hit the DOMContentLoaded event in less than 3.5 seconds.
// And presumably sites implementing service worker are on the
// higher end of the performance spectrum.
await timeout(3500);
}
}
const windows = await self.clients.matchAll({type: 'window'});

@@ -147,0 +177,0 @@ for (const win of windows) {

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc