|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | Copyright 2020 Google LLC
|
|---|
| 3 |
|
|---|
| 4 | Use of this source code is governed by an MIT-style
|
|---|
| 5 | license that can be found in the LICENSE file or at
|
|---|
| 6 | https://opensource.org/licenses/MIT.
|
|---|
| 7 | */
|
|---|
| 8 | import '../_version.js';
|
|---|
| 9 | /**
|
|---|
| 10 | * A plugin, designed to be used with PrecacheController, to determine the
|
|---|
| 11 | * of assets that were updated (or not updated) during the install event.
|
|---|
| 12 | *
|
|---|
| 13 | * @private
|
|---|
| 14 | */
|
|---|
| 15 | class PrecacheInstallReportPlugin {
|
|---|
| 16 | constructor() {
|
|---|
| 17 | this.updatedURLs = [];
|
|---|
| 18 | this.notUpdatedURLs = [];
|
|---|
| 19 | this.handlerWillStart = async ({ request, state, }) => {
|
|---|
| 20 | // TODO: `state` should never be undefined...
|
|---|
| 21 | if (state) {
|
|---|
| 22 | state.originalRequest = request;
|
|---|
| 23 | }
|
|---|
| 24 | };
|
|---|
| 25 | this.cachedResponseWillBeUsed = async ({ event, state, cachedResponse, }) => {
|
|---|
| 26 | if (event.type === 'install') {
|
|---|
| 27 | if (state &&
|
|---|
| 28 | state.originalRequest &&
|
|---|
| 29 | state.originalRequest instanceof Request) {
|
|---|
| 30 | // TODO: `state` should never be undefined...
|
|---|
| 31 | const url = state.originalRequest.url;
|
|---|
| 32 | if (cachedResponse) {
|
|---|
| 33 | this.notUpdatedURLs.push(url);
|
|---|
| 34 | }
|
|---|
| 35 | else {
|
|---|
| 36 | this.updatedURLs.push(url);
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 | return cachedResponse;
|
|---|
| 41 | };
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|
| 44 | export { PrecacheInstallReportPlugin };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.