@angular/service-worker 12.2.8 → 13.0.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/config.d.ts +1 -1
- package/config/package.json +5 -5
- package/{esm2015/config/config.js → esm2020/config/config.mjs} +0 -0
- package/{esm2015/config/index.js → esm2020/config/index.mjs} +0 -0
- package/{esm2015/config/public_api.js → esm2020/config/public_api.mjs} +0 -0
- package/{esm2015/config/src/duration.js → esm2020/config/src/duration.mjs} +0 -0
- package/{esm2015/config/src/filesystem.js → esm2020/config/src/filesystem.mjs} +0 -0
- package/esm2020/config/src/generator.mjs +147 -0
- package/{esm2015/config/src/glob.js → esm2020/config/src/glob.mjs} +0 -0
- package/{esm2015/config/src/in.js → esm2020/config/src/in.mjs} +0 -0
- package/{esm2015/index.js → esm2020/index.mjs} +0 -0
- package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
- package/esm2020/service-worker.mjs +5 -0
- package/{esm2015/src/index.js → esm2020/src/index.mjs} +0 -0
- package/esm2020/src/low_level.mjs +78 -0
- package/esm2020/src/module.mjs +128 -0
- package/esm2020/src/push.mjs +174 -0
- package/esm2020/src/update.mjs +61 -0
- package/fesm2015/{config.js → config.mjs} +2 -9
- package/fesm2015/config.mjs.map +1 -0
- package/fesm2015/{service-worker.js → service-worker.mjs} +23 -20
- package/fesm2015/service-worker.mjs.map +1 -0
- package/fesm2020/config.mjs +267 -0
- package/fesm2020/config.mjs.map +1 -0
- package/fesm2020/service-worker.mjs +463 -0
- package/fesm2020/service-worker.mjs.map +1 -0
- package/ngsw-config.js +169 -218
- package/ngsw-worker.js +1421 -1587
- package/package.json +36 -9
- package/service-worker.d.ts +29 -29
- package/bundles/service-worker-config.umd.js +0 -626
- package/bundles/service-worker-config.umd.js.map +0 -1
- package/bundles/service-worker.umd.js +0 -804
- package/bundles/service-worker.umd.js.map +0 -1
- package/config/config.metadata.json +0 -1
- package/config/index.ngfactory.d.ts +0 -2
- package/config/index.ngsummary.d.ts +0 -2
- package/config/public_api.ngfactory.d.ts +0 -2
- package/config/public_api.ngsummary.d.ts +0 -2
- package/config/src/duration.ngfactory.d.ts +0 -2
- package/config/src/duration.ngsummary.d.ts +0 -2
- package/config/src/filesystem.ngfactory.d.ts +0 -2
- package/config/src/filesystem.ngsummary.d.ts +0 -2
- package/config/src/generator.ngfactory.d.ts +0 -2
- package/config/src/generator.ngsummary.d.ts +0 -2
- package/config/src/glob.ngfactory.d.ts +0 -2
- package/config/src/glob.ngsummary.d.ts +0 -2
- package/config/src/in.ngfactory.d.ts +0 -2
- package/config/src/in.ngsummary.d.ts +0 -2
- package/config.d.ts +0 -7
- package/config.metadata.json +0 -1
- package/esm2015/config/config.externs.js +0 -6
- package/esm2015/config/src/generator.js +0 -150
- package/esm2015/service-worker.externs.js +0 -6
- package/esm2015/service-worker.js +0 -7
- package/esm2015/src/low_level.js +0 -75
- package/esm2015/src/module.js +0 -123
- package/esm2015/src/push.js +0 -173
- package/esm2015/src/update.js +0 -60
- package/fesm2015/config.js.map +0 -1
- package/fesm2015/service-worker.js.map +0 -1
- package/service-worker.metadata.json +0 -1
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Angular v13.0.0-next.11
|
|
3
|
+
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright Google LLC All Rights Reserved.
|
|
10
|
+
*
|
|
11
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
12
|
+
* found in the LICENSE file at https://angular.io/license
|
|
13
|
+
*/
|
|
14
|
+
const PARSE_TO_PAIRS = /([0-9]+[^0-9]+)/g;
|
|
15
|
+
const PAIR_SPLIT = /^([0-9]+)([dhmsu]+)$/;
|
|
16
|
+
function parseDurationToMs(duration) {
|
|
17
|
+
const matches = [];
|
|
18
|
+
let array;
|
|
19
|
+
while ((array = PARSE_TO_PAIRS.exec(duration)) !== null) {
|
|
20
|
+
matches.push(array[0]);
|
|
21
|
+
}
|
|
22
|
+
return matches
|
|
23
|
+
.map(match => {
|
|
24
|
+
const res = PAIR_SPLIT.exec(match);
|
|
25
|
+
if (res === null) {
|
|
26
|
+
throw new Error(`Not a valid duration: ${match}`);
|
|
27
|
+
}
|
|
28
|
+
let factor = 0;
|
|
29
|
+
switch (res[2]) {
|
|
30
|
+
case 'd':
|
|
31
|
+
factor = 86400000;
|
|
32
|
+
break;
|
|
33
|
+
case 'h':
|
|
34
|
+
factor = 3600000;
|
|
35
|
+
break;
|
|
36
|
+
case 'm':
|
|
37
|
+
factor = 60000;
|
|
38
|
+
break;
|
|
39
|
+
case 's':
|
|
40
|
+
factor = 1000;
|
|
41
|
+
break;
|
|
42
|
+
case 'u':
|
|
43
|
+
factor = 1;
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Not a valid duration unit: ${res[2]}`);
|
|
47
|
+
}
|
|
48
|
+
return parseInt(res[1]) * factor;
|
|
49
|
+
})
|
|
50
|
+
.reduce((total, value) => total + value, 0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @license
|
|
55
|
+
* Copyright Google LLC All Rights Reserved.
|
|
56
|
+
*
|
|
57
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
58
|
+
* found in the LICENSE file at https://angular.io/license
|
|
59
|
+
*/
|
|
60
|
+
const QUESTION_MARK = '[^/]';
|
|
61
|
+
const WILD_SINGLE = '[^/]*';
|
|
62
|
+
const WILD_OPEN = '(?:.+\\/)?';
|
|
63
|
+
const TO_ESCAPE_BASE = [
|
|
64
|
+
{ replace: /\./g, with: '\\.' },
|
|
65
|
+
{ replace: /\+/g, with: '\\+' },
|
|
66
|
+
{ replace: /\*/g, with: WILD_SINGLE },
|
|
67
|
+
];
|
|
68
|
+
const TO_ESCAPE_WILDCARD_QM = [
|
|
69
|
+
...TO_ESCAPE_BASE,
|
|
70
|
+
{ replace: /\?/g, with: QUESTION_MARK },
|
|
71
|
+
];
|
|
72
|
+
const TO_ESCAPE_LITERAL_QM = [
|
|
73
|
+
...TO_ESCAPE_BASE,
|
|
74
|
+
{ replace: /\?/g, with: '\\?' },
|
|
75
|
+
];
|
|
76
|
+
function globToRegex(glob, literalQuestionMark = false) {
|
|
77
|
+
const toEscape = literalQuestionMark ? TO_ESCAPE_LITERAL_QM : TO_ESCAPE_WILDCARD_QM;
|
|
78
|
+
const segments = glob.split('/').reverse();
|
|
79
|
+
let regex = '';
|
|
80
|
+
while (segments.length > 0) {
|
|
81
|
+
const segment = segments.pop();
|
|
82
|
+
if (segment === '**') {
|
|
83
|
+
if (segments.length > 0) {
|
|
84
|
+
regex += WILD_OPEN;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
regex += '.*';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const processed = toEscape.reduce((segment, escape) => segment.replace(escape.replace, escape.with), segment);
|
|
92
|
+
regex += processed;
|
|
93
|
+
if (segments.length > 0) {
|
|
94
|
+
regex += '\\/';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return regex;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @license
|
|
103
|
+
* Copyright Google LLC All Rights Reserved.
|
|
104
|
+
*
|
|
105
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
106
|
+
* found in the LICENSE file at https://angular.io/license
|
|
107
|
+
*/
|
|
108
|
+
const DEFAULT_NAVIGATION_URLS = [
|
|
109
|
+
'/**',
|
|
110
|
+
'!/**/*.*',
|
|
111
|
+
'!/**/*__*',
|
|
112
|
+
'!/**/*__*/**', // Exclude URLs containing `__` in any other segment.
|
|
113
|
+
];
|
|
114
|
+
/**
|
|
115
|
+
* Consumes service worker configuration files and processes them into control files.
|
|
116
|
+
*
|
|
117
|
+
* @publicApi
|
|
118
|
+
*/
|
|
119
|
+
class Generator {
|
|
120
|
+
constructor(fs, baseHref) {
|
|
121
|
+
this.fs = fs;
|
|
122
|
+
this.baseHref = baseHref;
|
|
123
|
+
}
|
|
124
|
+
async process(config) {
|
|
125
|
+
const unorderedHashTable = {};
|
|
126
|
+
const assetGroups = await this.processAssetGroups(config, unorderedHashTable);
|
|
127
|
+
return {
|
|
128
|
+
configVersion: 1,
|
|
129
|
+
timestamp: Date.now(),
|
|
130
|
+
appData: config.appData,
|
|
131
|
+
index: joinUrls(this.baseHref, config.index),
|
|
132
|
+
assetGroups,
|
|
133
|
+
dataGroups: this.processDataGroups(config),
|
|
134
|
+
hashTable: withOrderedKeys(unorderedHashTable),
|
|
135
|
+
navigationUrls: processNavigationUrls(this.baseHref, config.navigationUrls),
|
|
136
|
+
navigationRequestStrategy: config.navigationRequestStrategy ?? 'performance',
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
async processAssetGroups(config, hashTable) {
|
|
140
|
+
const seenMap = new Set();
|
|
141
|
+
return Promise.all((config.assetGroups || []).map(async (group) => {
|
|
142
|
+
if (group.resources.versionedFiles) {
|
|
143
|
+
throw new Error(`Asset-group '${group.name}' in 'ngsw-config.json' uses the 'versionedFiles' option, ` +
|
|
144
|
+
'which is no longer supported. Use \'files\' instead.');
|
|
145
|
+
}
|
|
146
|
+
const fileMatcher = globListToMatcher(group.resources.files || []);
|
|
147
|
+
const allFiles = await this.fs.list('/');
|
|
148
|
+
const matchedFiles = allFiles.filter(fileMatcher).filter(file => !seenMap.has(file)).sort();
|
|
149
|
+
matchedFiles.forEach(file => seenMap.add(file));
|
|
150
|
+
// Add the hashes.
|
|
151
|
+
await matchedFiles.reduce(async (previous, file) => {
|
|
152
|
+
await previous;
|
|
153
|
+
const hash = await this.fs.hash(file);
|
|
154
|
+
hashTable[joinUrls(this.baseHref, file)] = hash;
|
|
155
|
+
}, Promise.resolve());
|
|
156
|
+
return {
|
|
157
|
+
name: group.name,
|
|
158
|
+
installMode: group.installMode || 'prefetch',
|
|
159
|
+
updateMode: group.updateMode || group.installMode || 'prefetch',
|
|
160
|
+
cacheQueryOptions: buildCacheQueryOptions(group.cacheQueryOptions),
|
|
161
|
+
urls: matchedFiles.map(url => joinUrls(this.baseHref, url)),
|
|
162
|
+
patterns: (group.resources.urls || []).map(url => urlToRegex(url, this.baseHref, true)),
|
|
163
|
+
};
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
processDataGroups(config) {
|
|
167
|
+
return (config.dataGroups || []).map(group => {
|
|
168
|
+
return {
|
|
169
|
+
name: group.name,
|
|
170
|
+
patterns: group.urls.map(url => urlToRegex(url, this.baseHref, true)),
|
|
171
|
+
strategy: group.cacheConfig.strategy || 'performance',
|
|
172
|
+
maxSize: group.cacheConfig.maxSize,
|
|
173
|
+
maxAge: parseDurationToMs(group.cacheConfig.maxAge),
|
|
174
|
+
timeoutMs: group.cacheConfig.timeout && parseDurationToMs(group.cacheConfig.timeout),
|
|
175
|
+
cacheQueryOptions: buildCacheQueryOptions(group.cacheQueryOptions),
|
|
176
|
+
version: group.version !== undefined ? group.version : 1,
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function processNavigationUrls(baseHref, urls = DEFAULT_NAVIGATION_URLS) {
|
|
182
|
+
return urls.map(url => {
|
|
183
|
+
const positive = !url.startsWith('!');
|
|
184
|
+
url = positive ? url : url.substr(1);
|
|
185
|
+
return { positive, regex: `^${urlToRegex(url, baseHref)}$` };
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function globListToMatcher(globs) {
|
|
189
|
+
const patterns = globs.map(pattern => {
|
|
190
|
+
if (pattern.startsWith('!')) {
|
|
191
|
+
return {
|
|
192
|
+
positive: false,
|
|
193
|
+
regex: new RegExp('^' + globToRegex(pattern.substr(1)) + '$'),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
return {
|
|
198
|
+
positive: true,
|
|
199
|
+
regex: new RegExp('^' + globToRegex(pattern) + '$'),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return (file) => matches(file, patterns);
|
|
204
|
+
}
|
|
205
|
+
function matches(file, patterns) {
|
|
206
|
+
const res = patterns.reduce((isMatch, pattern) => {
|
|
207
|
+
if (pattern.positive) {
|
|
208
|
+
return isMatch || pattern.regex.test(file);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
return isMatch && !pattern.regex.test(file);
|
|
212
|
+
}
|
|
213
|
+
}, false);
|
|
214
|
+
return res;
|
|
215
|
+
}
|
|
216
|
+
function urlToRegex(url, baseHref, literalQuestionMark) {
|
|
217
|
+
if (!url.startsWith('/') && url.indexOf('://') === -1) {
|
|
218
|
+
// Prefix relative URLs with `baseHref`.
|
|
219
|
+
// Strip a leading `.` from a relative `baseHref` (e.g. `./foo/`), since it would result in an
|
|
220
|
+
// incorrect regex (matching a literal `.`).
|
|
221
|
+
url = joinUrls(baseHref.replace(/^\.(?=\/)/, ''), url);
|
|
222
|
+
}
|
|
223
|
+
return globToRegex(url, literalQuestionMark);
|
|
224
|
+
}
|
|
225
|
+
function joinUrls(a, b) {
|
|
226
|
+
if (a.endsWith('/') && b.startsWith('/')) {
|
|
227
|
+
return a + b.substr(1);
|
|
228
|
+
}
|
|
229
|
+
else if (!a.endsWith('/') && !b.startsWith('/')) {
|
|
230
|
+
return a + '/' + b;
|
|
231
|
+
}
|
|
232
|
+
return a + b;
|
|
233
|
+
}
|
|
234
|
+
function withOrderedKeys(unorderedObj) {
|
|
235
|
+
const orderedObj = {};
|
|
236
|
+
Object.keys(unorderedObj).sort().forEach(key => orderedObj[key] = unorderedObj[key]);
|
|
237
|
+
return orderedObj;
|
|
238
|
+
}
|
|
239
|
+
function buildCacheQueryOptions(inOptions) {
|
|
240
|
+
return {
|
|
241
|
+
ignoreVary: true,
|
|
242
|
+
...inOptions,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @license
|
|
248
|
+
* Copyright Google LLC All Rights Reserved.
|
|
249
|
+
*
|
|
250
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
251
|
+
* found in the LICENSE file at https://angular.io/license
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* @license
|
|
256
|
+
* Copyright Google LLC All Rights Reserved.
|
|
257
|
+
*
|
|
258
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
259
|
+
* found in the LICENSE file at https://angular.io/license
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Generated bundle index. Do not edit.
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
export { Generator };
|
|
267
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../../../../../../packages/service-worker/config/src/duration.ts","../../../../../../packages/service-worker/config/src/glob.ts","../../../../../../packages/service-worker/config/src/generator.ts","../../../../../../packages/service-worker/config/public_api.ts","../../../../../../packages/service-worker/config/index.ts","../../../../../../packages/service-worker/config/config.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nconst PARSE_TO_PAIRS = /([0-9]+[^0-9]+)/g;\nconst PAIR_SPLIT = /^([0-9]+)([dhmsu]+)$/;\n\nexport function parseDurationToMs(duration: string): number {\n const matches: string[] = [];\n\n let array: RegExpExecArray|null;\n while ((array = PARSE_TO_PAIRS.exec(duration)) !== null) {\n matches.push(array[0]);\n }\n return matches\n .map(match => {\n const res = PAIR_SPLIT.exec(match);\n if (res === null) {\n throw new Error(`Not a valid duration: ${match}`);\n }\n let factor: number = 0;\n switch (res[2]) {\n case 'd':\n factor = 86400000;\n break;\n case 'h':\n factor = 3600000;\n break;\n case 'm':\n factor = 60000;\n break;\n case 's':\n factor = 1000;\n break;\n case 'u':\n factor = 1;\n break;\n default:\n throw new Error(`Not a valid duration unit: ${res[2]}`);\n }\n return parseInt(res[1]) * factor;\n })\n .reduce((total, value) => total + value, 0);\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nconst QUESTION_MARK = '[^/]';\nconst WILD_SINGLE = '[^/]*';\nconst WILD_OPEN = '(?:.+\\\\/)?';\n\nconst TO_ESCAPE_BASE = [\n {replace: /\\./g, with: '\\\\.'},\n {replace: /\\+/g, with: '\\\\+'},\n {replace: /\\*/g, with: WILD_SINGLE},\n];\nconst TO_ESCAPE_WILDCARD_QM = [\n ...TO_ESCAPE_BASE,\n {replace: /\\?/g, with: QUESTION_MARK},\n];\nconst TO_ESCAPE_LITERAL_QM = [\n ...TO_ESCAPE_BASE,\n {replace: /\\?/g, with: '\\\\?'},\n];\n\nexport function globToRegex(glob: string, literalQuestionMark = false): string {\n const toEscape = literalQuestionMark ? TO_ESCAPE_LITERAL_QM : TO_ESCAPE_WILDCARD_QM;\n const segments = glob.split('/').reverse();\n let regex: string = '';\n while (segments.length > 0) {\n const segment = segments.pop()!;\n if (segment === '**') {\n if (segments.length > 0) {\n regex += WILD_OPEN;\n } else {\n regex += '.*';\n }\n } else {\n const processed = toEscape.reduce(\n (segment, escape) => segment.replace(escape.replace, escape.with), segment);\n regex += processed;\n if (segments.length > 0) {\n regex += '\\\\/';\n }\n }\n }\n return regex;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {parseDurationToMs} from './duration';\nimport {Filesystem} from './filesystem';\nimport {globToRegex} from './glob';\nimport {Config} from './in';\n\nconst DEFAULT_NAVIGATION_URLS = [\n '/**', // Include all URLs.\n '!/**/*.*', // Exclude URLs to files (containing a file extension in the last segment).\n '!/**/*__*', // Exclude URLs containing `__` in the last segment.\n '!/**/*__*/**', // Exclude URLs containing `__` in any other segment.\n];\n\n/**\n * Consumes service worker configuration files and processes them into control files.\n *\n * @publicApi\n */\nexport class Generator {\n constructor(readonly fs: Filesystem, private baseHref: string) {}\n\n async process(config: Config): Promise<Object> {\n const unorderedHashTable = {};\n const assetGroups = await this.processAssetGroups(config, unorderedHashTable);\n\n return {\n configVersion: 1,\n timestamp: Date.now(),\n appData: config.appData,\n index: joinUrls(this.baseHref, config.index),\n assetGroups,\n dataGroups: this.processDataGroups(config),\n hashTable: withOrderedKeys(unorderedHashTable),\n navigationUrls: processNavigationUrls(this.baseHref, config.navigationUrls),\n navigationRequestStrategy: config.navigationRequestStrategy ?? 'performance',\n };\n }\n\n private async processAssetGroups(config: Config, hashTable: {[file: string]: string|undefined}):\n Promise<Object[]> {\n const seenMap = new Set<string>();\n return Promise.all((config.assetGroups || []).map(async (group) => {\n if ((group.resources as any).versionedFiles) {\n throw new Error(\n `Asset-group '${group.name}' in 'ngsw-config.json' uses the 'versionedFiles' option, ` +\n 'which is no longer supported. Use \\'files\\' instead.');\n }\n\n const fileMatcher = globListToMatcher(group.resources.files || []);\n const allFiles = await this.fs.list('/');\n\n const matchedFiles = allFiles.filter(fileMatcher).filter(file => !seenMap.has(file)).sort();\n matchedFiles.forEach(file => seenMap.add(file));\n\n // Add the hashes.\n await matchedFiles.reduce(async (previous, file) => {\n await previous;\n const hash = await this.fs.hash(file);\n hashTable[joinUrls(this.baseHref, file)] = hash;\n }, Promise.resolve());\n\n return {\n name: group.name,\n installMode: group.installMode || 'prefetch',\n updateMode: group.updateMode || group.installMode || 'prefetch',\n cacheQueryOptions: buildCacheQueryOptions(group.cacheQueryOptions),\n urls: matchedFiles.map(url => joinUrls(this.baseHref, url)),\n patterns: (group.resources.urls || []).map(url => urlToRegex(url, this.baseHref, true)),\n };\n }));\n }\n\n private processDataGroups(config: Config): Object[] {\n return (config.dataGroups || []).map(group => {\n return {\n name: group.name,\n patterns: group.urls.map(url => urlToRegex(url, this.baseHref, true)),\n strategy: group.cacheConfig.strategy || 'performance',\n maxSize: group.cacheConfig.maxSize,\n maxAge: parseDurationToMs(group.cacheConfig.maxAge),\n timeoutMs: group.cacheConfig.timeout && parseDurationToMs(group.cacheConfig.timeout),\n cacheQueryOptions: buildCacheQueryOptions(group.cacheQueryOptions),\n version: group.version !== undefined ? group.version : 1,\n };\n });\n }\n}\n\nexport function processNavigationUrls(\n baseHref: string, urls = DEFAULT_NAVIGATION_URLS): {positive: boolean, regex: string}[] {\n return urls.map(url => {\n const positive = !url.startsWith('!');\n url = positive ? url : url.substr(1);\n return {positive, regex: `^${urlToRegex(url, baseHref)}$`};\n });\n}\n\nfunction globListToMatcher(globs: string[]): (file: string) => boolean {\n const patterns = globs.map(pattern => {\n if (pattern.startsWith('!')) {\n return {\n positive: false,\n regex: new RegExp('^' + globToRegex(pattern.substr(1)) + '$'),\n };\n } else {\n return {\n positive: true,\n regex: new RegExp('^' + globToRegex(pattern) + '$'),\n };\n }\n });\n return (file: string) => matches(file, patterns);\n}\n\nfunction matches(file: string, patterns: {positive: boolean, regex: RegExp}[]): boolean {\n const res = patterns.reduce((isMatch, pattern) => {\n if (pattern.positive) {\n return isMatch || pattern.regex.test(file);\n } else {\n return isMatch && !pattern.regex.test(file);\n }\n }, false);\n return res;\n}\n\nfunction urlToRegex(url: string, baseHref: string, literalQuestionMark?: boolean): string {\n if (!url.startsWith('/') && url.indexOf('://') === -1) {\n // Prefix relative URLs with `baseHref`.\n // Strip a leading `.` from a relative `baseHref` (e.g. `./foo/`), since it would result in an\n // incorrect regex (matching a literal `.`).\n url = joinUrls(baseHref.replace(/^\\.(?=\\/)/, ''), url);\n }\n\n return globToRegex(url, literalQuestionMark);\n}\n\nfunction joinUrls(a: string, b: string): string {\n if (a.endsWith('/') && b.startsWith('/')) {\n return a + b.substr(1);\n } else if (!a.endsWith('/') && !b.startsWith('/')) {\n return a + '/' + b;\n }\n return a + b;\n}\n\nfunction withOrderedKeys<T extends {[key: string]: any}>(unorderedObj: T): T {\n const orderedObj = {} as {[key: string]: any};\n Object.keys(unorderedObj).sort().forEach(key => orderedObj[key] = unorderedObj[key]);\n return orderedObj as T;\n}\n\nfunction buildCacheQueryOptions(inOptions?: Pick<CacheQueryOptions, 'ignoreSearch'>):\n CacheQueryOptions {\n return {\n ignoreVary: true,\n ...inOptions,\n };\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport {Filesystem} from './src/filesystem';\nexport {Generator} from './src/generator';\nexport {AssetGroup, Config, DataGroup, Duration, Glob} from './src/in';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;AAQA,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAC1C,MAAM,UAAU,GAAG,sBAAsB,CAAC;SAE1B,iBAAiB,CAAC,QAAgB;IAChD,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,IAAI,KAA2B,CAAC;IAChC,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE;QACvD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KACxB;IACD,OAAO,OAAO;SACT,GAAG,CAAC,KAAK;QACR,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,GAAG,KAAK,IAAI,EAAE;YAChB,MAAM,IAAI,KAAK,C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