v1.0 with SW PWA enabled
This commit is contained in:
44
frontend/node_modules/workbox-precaching/utils/PrecacheInstallReportPlugin.js
generated
vendored
Normal file
44
frontend/node_modules/workbox-precaching/utils/PrecacheInstallReportPlugin.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright 2020 Google LLC
|
||||
|
||||
Use of this source code is governed by an MIT-style
|
||||
license that can be found in the LICENSE file or at
|
||||
https://opensource.org/licenses/MIT.
|
||||
*/
|
||||
import '../_version.js';
|
||||
/**
|
||||
* A plugin, designed to be used with PrecacheController, to determine the
|
||||
* of assets that were updated (or not updated) during the install event.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
class PrecacheInstallReportPlugin {
|
||||
constructor() {
|
||||
this.updatedURLs = [];
|
||||
this.notUpdatedURLs = [];
|
||||
this.handlerWillStart = async ({ request, state, }) => {
|
||||
// TODO: `state` should never be undefined...
|
||||
if (state) {
|
||||
state.originalRequest = request;
|
||||
}
|
||||
};
|
||||
this.cachedResponseWillBeUsed = async ({ event, state, cachedResponse, }) => {
|
||||
if (event.type === 'install') {
|
||||
if (state &&
|
||||
state.originalRequest &&
|
||||
state.originalRequest instanceof Request) {
|
||||
// TODO: `state` should never be undefined...
|
||||
const url = state.originalRequest.url;
|
||||
if (cachedResponse) {
|
||||
this.notUpdatedURLs.push(url);
|
||||
}
|
||||
else {
|
||||
this.updatedURLs.push(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cachedResponse;
|
||||
};
|
||||
}
|
||||
}
|
||||
export { PrecacheInstallReportPlugin };
|
||||
Reference in New Issue
Block a user