Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(v2): Update workbox to v6 #4120

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/docusaurus-plugin-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"terser-webpack-plugin": "^4.1.0",
"webpack": "^4.44.1",
"webpack-merge": "^4.2.2",
"workbox-build": "^5.1.4",
"workbox-precaching": "^5.1.4",
"workbox-window": "^5.1.4"
"workbox-build": "^6.0.2",
"workbox-precaching": "^6.0.2",
"workbox-window": "^6.0.2"
},
"peerDependencies": {
"react": "^16.8.4",
Expand Down
28 changes: 14 additions & 14 deletions packages/docusaurus-plugin-pwa/src/registerSw.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function clearRegistrations() {
const registrations = await navigator.serviceWorker.getRegistrations();
if (debug && registrations.length > 0) {
console.log(
`[Docusaurus-PWA][registerSW]: unregister service workers`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just makes casing consistent with the file name

`[Docusaurus-PWA][registerSw]: unregister service workers`,
registrations,
);
}
Expand Down Expand Up @@ -58,12 +58,12 @@ function isOfflineModeEnabled() {
};
if (enabled) {
console.log(
'[Docusaurus-PWA][registerSW]: offline mode enabled, because of activation strategies',
'[Docusaurus-PWA][registerSw]: offline mode enabled, because of activation strategies',
logObject,
);
} else {
console.log(
'[Docusaurus-PWA][registerSW]: offline mode disabled, because none of the offlineModeActivationStrategies could be used',
'[Docusaurus-PWA][registerSw]: offline mode disabled, because none of the offlineModeActivationStrategies could be used',
logObject,
);
}
Expand All @@ -77,7 +77,7 @@ function createServiceWorkerUrl(params) {
paramsQueryString,
)}`;
if (debug) {
console.log(`[Docusaurus-PWA][registerSW]: service worker url`, {
console.log(`[Docusaurus-PWA][registerSw]: service worker url`, {
url,
params,
});
Expand All @@ -91,7 +91,7 @@ function createServiceWorkerUrl(params) {
}

if (debug) {
console.log('[Docusaurus-PWA][registerSW]: debug mode enabled');
console.log('[Docusaurus-PWA][registerSw]: debug mode enabled');
}

if ('serviceWorker' in navigator) {
Expand All @@ -108,7 +108,7 @@ function createServiceWorkerUrl(params) {

const handleServiceWorkerWaiting = async () => {
if (debug) {
console.log('[Docusaurus-PWA][registerSW]: handleServiceWorkerWaiting');
console.log('[Docusaurus-PWA][registerSw]: handleServiceWorkerWaiting');
}
// Immediately load new service worker when files aren't cached
if (!offlineMode) {
Expand All @@ -129,19 +129,19 @@ function createServiceWorkerUrl(params) {
if (debug) {
if (registration.active) {
console.log(
'[Docusaurus-PWA][registerSW]: registration.active',
'[Docusaurus-PWA][registerSw]: registration.active',
registration,
);
}
if (registration.installing) {
console.log(
'[Docusaurus-PWA][registerSW]: registration.installing',
'[Docusaurus-PWA][registerSw]: registration.installing',
registration,
);
}
if (registration.waiting) {
console.log(
'[Docusaurus-PWA][registerSW]: registration.waiting',
'[Docusaurus-PWA][registerSw]: registration.waiting',
registration,
);
}
Expand All @@ -157,7 +157,7 @@ function createServiceWorkerUrl(params) {
// installing and transitions to waiting state.
wb.addEventListener('waiting', (event) => {
if (debug) {
console.log('[Docusaurus-PWA][registerSW]: event waiting', event);
console.log('[Docusaurus-PWA][registerSw]: event waiting', event);
}
handleServiceWorkerWaiting();
});
Expand All @@ -167,7 +167,7 @@ function createServiceWorkerUrl(params) {
wb.addEventListener('externalwaiting', (event) => {
if (debug) {
console.log(
'[Docusaurus-PWA][registerSW]: event externalwaiting',
'[Docusaurus-PWA][registerSw]: event externalwaiting',
event,
);
}
Expand All @@ -176,7 +176,7 @@ function createServiceWorkerUrl(params) {

window.addEventListener('appinstalled', (event) => {
if (debug) {
console.log('[Docusaurus-PWA][registerSW]: event appinstalled', event);
console.log('[Docusaurus-PWA][registerSw]: event appinstalled', event);
}
localStorage.setItem(APP_INSTALLED_KEY, true);

Expand All @@ -189,7 +189,7 @@ function createServiceWorkerUrl(params) {

window.addEventListener('beforeinstallprompt', (event) => {
if (debug) {
console.log('[Docusaurus-PWA][registerSW]: event appinstalled', event);
console.log('[Docusaurus-PWA][registerSw]: event appinstalled', event);
}
// TODO instead of default browser install UI, show custom docusaurus prompt?
// event.preventDefault();
Expand All @@ -205,7 +205,7 @@ function createServiceWorkerUrl(params) {
});
} else if (debug) {
console.log(
'[Docusaurus-PWA][registerSW]: browser does not support service workers',
'[Docusaurus-PWA][registerSw]: browser does not support service workers',
);
}
})();
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-pwa/src/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function runSWCustomCode(params) {
* Gets different possible variations for a request URL. Similar to
* https://git.io/JvixK
*
* @param {String} url
* @param {string} url
*/
function getPossibleURLs(url) {
const possibleURLs = [];
Expand Down
Loading