source: frontend/node_modules/workbox-build/src/lib/additional-manifest-entries-transform.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 Copyright 2019 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
9import {errors} from './errors';
10import {ManifestEntry} from '../types';
11
12type AdditionalManifestEntriesTransform = {
13 (manifest: Array<ManifestEntry & {size: number}>): {
14 manifest: Array<ManifestEntry & {size: number}>;
15 warnings: string[];
16 };
17};
18
19export function additionalManifestEntriesTransform(
20 additionalManifestEntries: Array<ManifestEntry | string>,
21): AdditionalManifestEntriesTransform {
22 return (manifest: Array<ManifestEntry & {size: number}>) => {
23 const warnings: Array<string> = [];
24 const stringEntries = new Set<string>();
25
26 for (const additionalEntry of additionalManifestEntries) {
27 // Warn about either a string or an object that lacks a revision property.
28 // (An object with a revision property set to null is okay.)
29 if (typeof additionalEntry === 'string') {
30 stringEntries.add(additionalEntry);
31 manifest.push({
32 revision: null,
33 size: 0,
34 url: additionalEntry,
35 });
36 } else {
37 if (additionalEntry && additionalEntry.revision === undefined) {
38 stringEntries.add(additionalEntry.url);
39 }
40 manifest.push(Object.assign({size: 0}, additionalEntry));
41 }
42 }
43
44 if (stringEntries.size > 0) {
45 let urls = '\n';
46 for (const stringEntry of stringEntries) {
47 urls += ` - ${stringEntry}\n`;
48 }
49
50 warnings.push(errors['string-entry-warning'] + urls);
51 }
52
53 return {
54 manifest,
55 warnings,
56 };
57 };
58}
Note: See TracBrowser for help on using the repository browser.