Urara-Blog/node_modules/.pnpm-store/v3/files/6e/fa23b705f234c30f966fc0416dcb6085829a2b567695e7125c2058b11883ff77b53842c4c4510748512db86fa7b8b30b8a270078902eb296f9eaf9a1e013ea
2022-08-14 01:14:53 +08:00

44 lines
1.4 KiB
Text

/*
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 };