@serwist/precaching 8.4.4 → 9.0.0-preview.0
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/dist/PrecacheController.d.ts +4 -3
- package/dist/PrecacheController.d.ts.map +1 -0
- package/dist/PrecacheFallbackPlugin.d.ts +1 -0
- package/dist/PrecacheFallbackPlugin.d.ts.map +1 -0
- package/dist/PrecacheRoute.d.ts +1 -0
- package/dist/PrecacheRoute.d.ts.map +1 -0
- package/dist/PrecacheStrategy.d.ts +1 -0
- package/dist/PrecacheStrategy.d.ts.map +1 -0
- package/dist/_types.d.ts +3 -2
- package/dist/_types.d.ts.map +1 -0
- package/dist/addPlugins.d.ts +1 -0
- package/dist/addPlugins.d.ts.map +1 -0
- package/dist/addRoute.d.ts +1 -0
- package/dist/addRoute.d.ts.map +1 -0
- package/dist/cleanupOutdatedCaches.d.ts +1 -0
- package/dist/cleanupOutdatedCaches.d.ts.map +1 -0
- package/dist/createHandlerBoundToURL.d.ts +1 -0
- package/dist/createHandlerBoundToURL.d.ts.map +1 -0
- package/dist/getCacheKeyForURL.d.ts +1 -0
- package/dist/getCacheKeyForURL.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/matchPrecache.d.ts +1 -0
- package/dist/matchPrecache.d.ts.map +1 -0
- package/dist/precache.d.ts +2 -1
- package/dist/precache.d.ts.map +1 -0
- package/dist/precacheAndRoute.d.ts +2 -1
- package/dist/precacheAndRoute.d.ts.map +1 -0
- package/dist/utils/PrecacheCacheKeyPlugin.d.ts +1 -0
- package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -0
- package/dist/utils/PrecacheInstallReportPlugin.d.ts +1 -0
- package/dist/utils/PrecacheInstallReportPlugin.d.ts.map +1 -0
- package/dist/utils/createCacheKey.d.ts +1 -0
- package/dist/utils/createCacheKey.d.ts.map +1 -0
- package/dist/utils/deleteOutdatedCaches.d.ts +1 -0
- package/dist/utils/deleteOutdatedCaches.d.ts.map +1 -0
- package/dist/utils/generateURLVariations.d.ts +1 -0
- package/dist/utils/generateURLVariations.d.ts.map +1 -0
- package/dist/utils/getCacheKeyForURL.d.ts +1 -0
- package/dist/utils/getCacheKeyForURL.d.ts.map +1 -0
- package/dist/utils/getOrCreatePrecacheController.d.ts +1 -0
- package/dist/utils/getOrCreatePrecacheController.d.ts.map +1 -0
- package/dist/utils/printCleanupDetails.d.ts +1 -0
- package/dist/utils/printCleanupDetails.d.ts.map +1 -0
- package/dist/utils/printInstallDetails.d.ts +1 -0
- package/dist/utils/printInstallDetails.d.ts.map +1 -0
- package/dist/utils/removeIgnoredSearchParams.d.ts +1 -0
- package/dist/utils/removeIgnoredSearchParams.d.ts.map +1 -0
- package/package.json +20 -18
- package/src/PrecacheController.ts +331 -0
- package/src/PrecacheFallbackPlugin.ts +61 -0
- package/src/PrecacheRoute.ts +50 -0
- package/src/PrecacheStrategy.ts +239 -0
- package/src/_types.ts +46 -0
- package/src/addPlugins.ts +23 -0
- package/src/addRoute.ts +33 -0
- package/src/cleanupOutdatedCaches.ts +34 -0
- package/src/createHandlerBoundToURL.ts +32 -0
- package/src/getCacheKeyForURL.ts +33 -0
- package/{dist/index.d.cts → src/index.ts} +25 -1
- package/src/matchPrecache.ts +28 -0
- package/src/precache.ts +33 -0
- package/src/precacheAndRoute.ts +29 -0
- package/src/utils/PrecacheCacheKeyPlugin.ts +36 -0
- package/src/utils/PrecacheInstallReportPlugin.ts +49 -0
- package/src/utils/createCacheKey.ts +68 -0
- package/src/utils/deleteOutdatedCaches.ts +42 -0
- package/src/utils/generateURLVariations.ts +55 -0
- package/src/utils/getCacheKeyForURL.ts +36 -0
- package/src/utils/getOrCreatePrecacheController.ts +22 -0
- package/src/utils/printCleanupDetails.ts +38 -0
- package/src/utils/printInstallDetails.ts +53 -0
- package/src/utils/removeIgnoredSearchParams.ts +29 -0
- package/dist/index.cjs +0 -930
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2018 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
|
+
|
|
9
|
+
import { logger } from "@serwist/core/internal";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param groupTitle
|
|
13
|
+
* @param deletedURLs
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
const logGroup = (groupTitle: string, deletedURLs: string[]) => {
|
|
18
|
+
logger.groupCollapsed(groupTitle);
|
|
19
|
+
|
|
20
|
+
for (const url of deletedURLs) {
|
|
21
|
+
logger.log(url);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
logger.groupEnd();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param deletedURLs
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
31
|
+
export function printCleanupDetails(deletedURLs: string[]): void {
|
|
32
|
+
const deletionCount = deletedURLs.length;
|
|
33
|
+
if (deletionCount > 0) {
|
|
34
|
+
logger.groupCollapsed(`During precaching cleanup, ${deletionCount} cached request${deletionCount === 1 ? " was" : "s were"} deleted.`);
|
|
35
|
+
logGroup("Deleted Cache Requests", deletedURLs);
|
|
36
|
+
logger.groupEnd();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2018 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
|
+
|
|
9
|
+
import { logger } from "@serwist/core/internal";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param groupTitle
|
|
13
|
+
* @param urls
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
function _nestedGroup(groupTitle: string, urls: string[]): void {
|
|
18
|
+
if (urls.length === 0) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
logger.groupCollapsed(groupTitle);
|
|
23
|
+
|
|
24
|
+
for (const url of urls) {
|
|
25
|
+
logger.log(url);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
logger.groupEnd();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param urlsToPrecache
|
|
33
|
+
* @param urlsAlreadyPrecached
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
export function printInstallDetails(urlsToPrecache: string[], urlsAlreadyPrecached: string[]): void {
|
|
37
|
+
const precachedCount = urlsToPrecache.length;
|
|
38
|
+
const alreadyPrecachedCount = urlsAlreadyPrecached.length;
|
|
39
|
+
|
|
40
|
+
if (precachedCount || alreadyPrecachedCount) {
|
|
41
|
+
let message = `Precaching ${precachedCount} file${precachedCount === 1 ? "" : "s"}.`;
|
|
42
|
+
|
|
43
|
+
if (alreadyPrecachedCount > 0) {
|
|
44
|
+
message += ` ${alreadyPrecachedCount} ` + `file${alreadyPrecachedCount === 1 ? " is" : "s are"} already cached.`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
logger.groupCollapsed(message);
|
|
48
|
+
|
|
49
|
+
_nestedGroup("View newly precached URLs.", urlsToPrecache);
|
|
50
|
+
_nestedGroup("View previously precached URLs.", urlsAlreadyPrecached);
|
|
51
|
+
logger.groupEnd();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2018 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
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Removes any URL search parameters that should be ignored.
|
|
11
|
+
*
|
|
12
|
+
* @param urlObject The original URL.
|
|
13
|
+
* @param ignoreURLParametersMatching RegExps to test against
|
|
14
|
+
* each search parameter name. Matches mean that the search parameter should be
|
|
15
|
+
* ignored.
|
|
16
|
+
* @returns The URL with any ignored search parameters removed.
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
export function removeIgnoredSearchParams(urlObject: URL, ignoreURLParametersMatching: RegExp[] = []): URL {
|
|
20
|
+
// Convert the iterable into an array at the start of the loop to make sure
|
|
21
|
+
// deletion doesn't mess up iteration.
|
|
22
|
+
for (const paramName of [...urlObject.searchParams.keys()]) {
|
|
23
|
+
if (ignoreURLParametersMatching.some((regExp) => regExp.test(paramName))) {
|
|
24
|
+
urlObject.searchParams.delete(paramName);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return urlObject;
|
|
29
|
+
}
|