@serwist/precaching 9.0.0-preview.16 → 9.0.0-preview.18

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.
Files changed (74) hide show
  1. package/dist/index.d.ts +5 -26
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -584
  4. package/package.json +3 -6
  5. package/src/index.ts +5 -39
  6. package/dist/PrecacheController.d.ts +0 -146
  7. package/dist/PrecacheController.d.ts.map +0 -1
  8. package/dist/PrecacheFallbackPlugin.d.ts +0 -54
  9. package/dist/PrecacheFallbackPlugin.d.ts.map +0 -1
  10. package/dist/PrecacheRoute.d.ts +0 -20
  11. package/dist/PrecacheRoute.d.ts.map +0 -1
  12. package/dist/PrecacheStrategy.d.ts +0 -67
  13. package/dist/PrecacheStrategy.d.ts.map +0 -1
  14. package/dist/_types.d.ts +0 -37
  15. package/dist/_types.d.ts.map +0 -1
  16. package/dist/addPlugins.d.ts +0 -9
  17. package/dist/addPlugins.d.ts.map +0 -1
  18. package/dist/addRoute.d.ts +0 -15
  19. package/dist/addRoute.d.ts.map +0 -1
  20. package/dist/cleanupOutdatedCaches.d.ts +0 -6
  21. package/dist/cleanupOutdatedCaches.d.ts.map +0 -1
  22. package/dist/createHandlerBoundToURL.d.ts +0 -17
  23. package/dist/createHandlerBoundToURL.d.ts.map +0 -1
  24. package/dist/getCacheKeyForURL.d.ts +0 -20
  25. package/dist/getCacheKeyForURL.d.ts.map +0 -1
  26. package/dist/matchPrecache.d.ts +0 -15
  27. package/dist/matchPrecache.d.ts.map +0 -1
  28. package/dist/precache.d.ts +0 -19
  29. package/dist/precache.d.ts.map +0 -1
  30. package/dist/precacheAndRoute.d.ts +0 -14
  31. package/dist/precacheAndRoute.d.ts.map +0 -1
  32. package/dist/utils/PrecacheCacheKeyPlugin.d.ts +0 -17
  33. package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +0 -1
  34. package/dist/utils/PrecacheInstallReportPlugin.d.ts +0 -15
  35. package/dist/utils/PrecacheInstallReportPlugin.d.ts.map +0 -1
  36. package/dist/utils/createCacheKey.d.ts +0 -16
  37. package/dist/utils/createCacheKey.d.ts.map +0 -1
  38. package/dist/utils/deleteOutdatedCaches.d.ts +0 -18
  39. package/dist/utils/deleteOutdatedCaches.d.ts.map +0 -1
  40. package/dist/utils/generateURLVariations.d.ts +0 -12
  41. package/dist/utils/generateURLVariations.d.ts.map +0 -1
  42. package/dist/utils/getCacheKeyForURL.d.ts +0 -14
  43. package/dist/utils/getCacheKeyForURL.d.ts.map +0 -1
  44. package/dist/utils/getOrCreatePrecacheController.d.ts +0 -7
  45. package/dist/utils/getOrCreatePrecacheController.d.ts.map +0 -1
  46. package/dist/utils/printCleanupDetails.d.ts +0 -6
  47. package/dist/utils/printCleanupDetails.d.ts.map +0 -1
  48. package/dist/utils/printInstallDetails.d.ts +0 -7
  49. package/dist/utils/printInstallDetails.d.ts.map +0 -1
  50. package/dist/utils/removeIgnoredSearchParams.d.ts +0 -12
  51. package/dist/utils/removeIgnoredSearchParams.d.ts.map +0 -1
  52. package/src/PrecacheController.ts +0 -344
  53. package/src/PrecacheFallbackPlugin.ts +0 -86
  54. package/src/PrecacheRoute.ts +0 -50
  55. package/src/PrecacheStrategy.ts +0 -239
  56. package/src/_types.ts +0 -46
  57. package/src/addPlugins.ts +0 -23
  58. package/src/addRoute.ts +0 -31
  59. package/src/cleanupOutdatedCaches.ts +0 -33
  60. package/src/createHandlerBoundToURL.ts +0 -30
  61. package/src/getCacheKeyForURL.ts +0 -33
  62. package/src/matchPrecache.ts +0 -28
  63. package/src/precache.ts +0 -31
  64. package/src/precacheAndRoute.ts +0 -27
  65. package/src/utils/PrecacheCacheKeyPlugin.ts +0 -36
  66. package/src/utils/PrecacheInstallReportPlugin.ts +0 -49
  67. package/src/utils/createCacheKey.ts +0 -68
  68. package/src/utils/deleteOutdatedCaches.ts +0 -40
  69. package/src/utils/generateURLVariations.ts +0 -55
  70. package/src/utils/getCacheKeyForURL.ts +0 -36
  71. package/src/utils/getOrCreatePrecacheController.ts +0 -22
  72. package/src/utils/printCleanupDetails.ts +0 -38
  73. package/src/utils/printInstallDetails.ts +0 -53
  74. package/src/utils/removeIgnoredSearchParams.ts +0 -29
package/src/index.ts CHANGED
@@ -1,36 +1,3 @@
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 { PrecacheController } from "./PrecacheController.js";
10
- import { PrecacheFallbackPlugin } from "./PrecacheFallbackPlugin.js";
11
- import type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "./PrecacheFallbackPlugin.js";
12
- import { PrecacheRoute } from "./PrecacheRoute.js";
13
- import { PrecacheStrategy } from "./PrecacheStrategy.js";
14
- import { addPlugins } from "./addPlugins.js";
15
- import { addRoute } from "./addRoute.js";
16
- import { cleanupOutdatedCaches } from "./cleanupOutdatedCaches.js";
17
- import { createHandlerBoundToURL } from "./createHandlerBoundToURL.js";
18
- import { getCacheKeyForURL } from "./getCacheKeyForURL.js";
19
- import { matchPrecache } from "./matchPrecache.js";
20
- import { precache } from "./precache.js";
21
- import { precacheAndRoute } from "./precacheAndRoute.js";
22
-
23
- /**
24
- * Most consumers of this module will want to use the
25
- * `@serwist/precaching.precacheAndRoute`
26
- * method to add assets to the cache and respond to network requests with these
27
- * cached assets.
28
- *
29
- * If you require more control over caching and routing, you can use the
30
- * `@serwist/precaching.PrecacheController`
31
- * interface.
32
- */
33
-
34
1
  export {
35
2
  addPlugins,
36
3
  addRoute,
@@ -41,11 +8,10 @@ export {
41
8
  precache,
42
9
  precacheAndRoute,
43
10
  PrecacheController,
44
- PrecacheFallbackPlugin,
45
11
  PrecacheRoute,
46
12
  PrecacheStrategy,
47
- };
48
-
49
- export type * from "./_types.js";
50
-
51
- export type { PrecacheFallbackPluginOptions, PrecacheFallbackEntry };
13
+ } from "@serwist/sw/precaching";
14
+ export { PrecacheFallbackPlugin } from "@serwist/sw/plugins";
15
+ export type * from "@serwist/sw/precaching";
16
+ export type { UrlManipulation as urlManipulation } from "@serwist/sw/precaching";
17
+ export type { PrecacheFallbackEntry, PrecacheFallbackPluginOptions } from "@serwist/sw/plugins";
@@ -1,146 +0,0 @@
1
- import type { RouteHandlerCallback, SerwistPlugin } from "@serwist/core";
2
- import type { Strategy } from "@serwist/strategies";
3
- import type { CleanupResult, InstallResult, PrecacheEntry } from "./_types.js";
4
- interface PrecacheControllerOptions {
5
- /**
6
- * The cache to use for precaching.
7
- */
8
- cacheName?: string;
9
- /**
10
- * Plugins to use when precaching as well as responding to fetch
11
- * events for precached assets.
12
- */
13
- plugins?: SerwistPlugin[];
14
- /**
15
- * Whether to attempt to get the response from the network if there's
16
- * a precache miss.
17
- */
18
- fallbackToNetwork?: boolean;
19
- /**
20
- * A number of how many precache requests should be made concurrently.
21
- * By default, this value is set to 1, but this can be overriden by
22
- * setting this option or `self.__WB_CONCURRENT_PRECACHING`. The former takes
23
- * precedence over the latter.
24
- */
25
- concurrentPrecaching?: number;
26
- }
27
- /**
28
- * Performs efficient precaching of assets.
29
- */
30
- export declare class PrecacheController {
31
- private _installAndActiveListenersAdded?;
32
- private _concurrentPrecaching;
33
- private readonly _strategy;
34
- private readonly _urlsToCacheKeys;
35
- private readonly _urlsToCacheModes;
36
- private readonly _cacheKeysToIntegrities;
37
- /**
38
- * Create a new PrecacheController.
39
- *
40
- * @param options
41
- */
42
- constructor({ cacheName, plugins, fallbackToNetwork, concurrentPrecaching }?: PrecacheControllerOptions);
43
- /**
44
- * The strategy created by this controller and
45
- * used to cache assets and respond to fetch events.
46
- */
47
- get strategy(): Strategy;
48
- /**
49
- * Adds items to the precache list, removing any duplicates and
50
- * stores the files in the precache cache when the service
51
- * worker installs.
52
- *
53
- * This method can be called multiple times.
54
- *
55
- * @param entries Array of entries to precache.
56
- */
57
- precache(entries: (PrecacheEntry | string)[]): void;
58
- /**
59
- * This method will add items to the precache list, removing duplicates
60
- * and ensuring the information is valid.
61
- *
62
- * @param entries Array of entries to precache.
63
- */
64
- addToCacheList(entries: (PrecacheEntry | string)[]): void;
65
- /**
66
- * Precaches new and updated assets. Call this method from the service worker
67
- * install event.
68
- *
69
- * Note: this method calls `event.waitUntil()` for you, so you do not need
70
- * to call it yourself in your event handlers.
71
- *
72
- * @param event
73
- * @returns
74
- */
75
- install(event: ExtendableEvent): Promise<InstallResult>;
76
- /**
77
- * Deletes assets that are no longer present in the current precache manifest.
78
- * Call this method from the service worker activate event.
79
- *
80
- * Note: this method calls `event.waitUntil()` for you, so you do not need
81
- * to call it yourself in your event handlers.
82
- *
83
- * @param event
84
- * @returns
85
- */
86
- activate(event: ExtendableEvent): Promise<CleanupResult>;
87
- /**
88
- * Returns a mapping of a precached URL to the corresponding cache key, taking
89
- * into account the revision information for the URL.
90
- *
91
- * @returns A URL to cache key mapping.
92
- */
93
- getURLsToCacheKeys(): Map<string, string>;
94
- /**
95
- * Returns a list of all the URLs that have been precached by the current
96
- * service worker.
97
- *
98
- * @returns The precached URLs.
99
- */
100
- getCachedURLs(): string[];
101
- /**
102
- * Returns the cache key used for storing a given URL. If that URL is
103
- * unversioned, like `/index.html', then the cache key will be the original
104
- * URL with a search parameter appended to it.
105
- *
106
- * @param url A URL whose cache key you want to look up.
107
- * @returns The versioned URL that corresponds to a cache key
108
- * for the original URL, or undefined if that URL isn't precached.
109
- */
110
- getCacheKeyForURL(url: string): string | undefined;
111
- /**
112
- * @param url A cache key whose SRI you want to look up.
113
- * @returns The subresource integrity associated with the cache key,
114
- * or undefined if it's not set.
115
- */
116
- getIntegrityForCacheKey(cacheKey: string): string | undefined;
117
- /**
118
- * This acts as a drop-in replacement for
119
- * [`cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match)
120
- * with the following differences:
121
- *
122
- * - It knows what the name of the precache is, and only checks in that cache.
123
- * - It allows you to pass in an "original" URL without versioning parameters,
124
- * and it will automatically look up the correct cache key for the currently
125
- * active revision of that URL.
126
- *
127
- * E.g., `matchPrecache('index.html')` will find the correct precached
128
- * response for the currently active service worker, even if the actual cache
129
- * key is `'/index.html?__WB_REVISION__=1234abcd'`.
130
- *
131
- * @param request The key (without revisioning parameters)
132
- * to look up in the precache.
133
- * @returns
134
- */
135
- matchPrecache(request: string | Request): Promise<Response | undefined>;
136
- /**
137
- * Returns a function that looks up `url` in the precache (taking into
138
- * account revision information), and returns the corresponding `Response`.
139
- *
140
- * @param url The precached URL which will be used to lookup the response.
141
- * @return
142
- */
143
- createHandlerBoundToURL(url: string): RouteHandlerCallback;
144
- }
145
- export {};
146
- //# sourceMappingURL=PrecacheController.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrecacheController.d.ts","sourceRoot":"","sources":["../src/PrecacheController.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAIpD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAU/E,UAAU,yBAAyB;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,+BAA+B,CAAC,CAAU;IAClD,OAAO,CAAC,qBAAqB,CAAqB;IAClD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAW;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkC;IACnE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6G;IAC/I,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAkC;IAE1E;;;;OAIG;gBACS,EAAE,SAAS,EAAE,OAAY,EAAE,iBAAwB,EAAE,oBAAoB,EAAE,GAAE,yBAA8B;IAavH;;;OAGG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI;IAUnD;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI;IAwDzD;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IA4CvD;;;;;;;;;OASG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAuBxD;;;;;OAKG;IACH,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC;;;;;OAKG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAKlD;;;;OAIG;IACH,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI7D;;;;;;;;;;;;;;;;;OAiBG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IAU7E;;;;;;OAMG;IACH,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB;CAY3D"}
@@ -1,54 +0,0 @@
1
- import type { HandlerDidErrorCallbackParam, SerwistPlugin } from "@serwist/core";
2
- import type { PrecacheController } from "./PrecacheController.js";
3
- export interface PrecacheFallbackEntry {
4
- /**
5
- * A function that checks whether the fallback entry can be used
6
- * for a request.
7
- */
8
- matcher: (param: HandlerDidErrorCallbackParam) => boolean;
9
- /**
10
- * A precached URL to be used as a fallback.
11
- */
12
- url: string;
13
- }
14
- export interface PrecacheFallbackPluginOptions {
15
- /**
16
- * Precached URLs to use as the fallback
17
- * if the associated strategy can't generate a response.
18
- */
19
- fallbackUrls: (string | PrecacheFallbackEntry)[];
20
- /**
21
- * An optional `PrecacheController` instance. If not provided, the default
22
- * `PrecacheController` will be used.
23
- */
24
- precacheController?: PrecacheController;
25
- }
26
- /**
27
- * `PrecacheFallbackPlugin` allows you to specify offline fallbacks
28
- * to be used when a given strategy is unable to generate a response.
29
- *
30
- * It does this by intercepting the `handlerDidError` plugin callback
31
- * and returning a precached response, taking the expected revision parameter
32
- * into account automatically.
33
- *
34
- * Unless you explicitly pass in a `PrecacheController` instance to the
35
- * constructor, the default instance will be used. Generally speaking, most
36
- * developers will end up using the default.
37
- */
38
- export declare class PrecacheFallbackPlugin implements SerwistPlugin {
39
- private readonly _fallbackUrls;
40
- private readonly _precacheController;
41
- /**
42
- * Constructs a new `PrecacheFallbackPlugin` with the associated `fallbackUrls`.
43
- *
44
- * @param config
45
- */
46
- constructor({ fallbackUrls, precacheController }: PrecacheFallbackPluginOptions);
47
- /**
48
- * @returns The precache response for one of the fallback URLs, or `undefined` if
49
- * nothing satisfies the conditions.
50
- * @private
51
- */
52
- handlerDidError(param: HandlerDidErrorCallbackParam): Promise<Response | undefined>;
53
- }
54
- //# sourceMappingURL=PrecacheFallbackPlugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrecacheFallbackPlugin.d.ts","sourceRoot":"","sources":["../src/PrecacheFallbackPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,4BAA4B,KAAK,OAAO,CAAC;IAC1D;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,YAAY,EAAE,CAAC,MAAM,GAAG,qBAAqB,CAAC,EAAE,CAAC;IACjD;;;OAGG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,sBAAuB,YAAW,aAAa;IAC1D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqC;IACnE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;IAEzD;;;;OAIG;gBACS,EAAE,YAAY,EAAE,kBAAkB,EAAE,EAAE,6BAA6B;IAK/E;;;;OAIG;IACG,eAAe,CAAC,KAAK,EAAE,4BAA4B;CAgB1D"}
@@ -1,20 +0,0 @@
1
- import { Route } from "@serwist/routing";
2
- import type { PrecacheController } from "./PrecacheController.js";
3
- import type { PrecacheRouteOptions } from "./_types.js";
4
- /**
5
- * A subclass of `@serwist/routing.Route` that takes a
6
- * `@serwist/precaching.PrecacheController`
7
- * instance and uses it to match incoming requests and handle fetching
8
- * responses from the precache.
9
- */
10
- declare class PrecacheRoute extends Route {
11
- /**
12
- * @param precacheController A `PrecacheController`
13
- * instance used to both match requests and respond to fetch events.
14
- * @param options Options to control how requests are matched
15
- * against the list of precached URLs.
16
- */
17
- constructor(precacheController: PrecacheController, options?: PrecacheRouteOptions);
18
- }
19
- export { PrecacheRoute };
20
- //# sourceMappingURL=PrecacheRoute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrecacheRoute.d.ts","sourceRoot":"","sources":["../src/PrecacheRoute.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD;;;;;GAKG;AACH,cAAM,aAAc,SAAQ,KAAK;IAC/B;;;;;OAKG;gBACS,kBAAkB,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,oBAAoB;CAkBnF;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,67 +0,0 @@
1
- import type { SerwistPlugin } from "@serwist/core";
2
- import type { StrategyHandler, StrategyOptions } from "@serwist/strategies";
3
- import { Strategy } from "@serwist/strategies";
4
- interface PrecacheStrategyOptions extends StrategyOptions {
5
- /**
6
- * Whether to attempt to get the response from the network
7
- * if there's a precache miss.
8
- */
9
- fallbackToNetwork?: boolean;
10
- }
11
- /**
12
- * A `@serwist/strategies.Strategy` implementation
13
- * specifically designed to work with
14
- * `@serwist/precaching.PrecacheController`
15
- * to both cache and fetch precached assets.
16
- *
17
- * Note: an instance of this class is created automatically when creating a
18
- * `PrecacheController`; it's generally not necessary to create this yourself.
19
- */
20
- declare class PrecacheStrategy extends Strategy {
21
- private readonly _fallbackToNetwork;
22
- static readonly defaultPrecacheCacheabilityPlugin: SerwistPlugin;
23
- static readonly copyRedirectedCacheableResponsesPlugin: SerwistPlugin;
24
- /**
25
- * @param options
26
- */
27
- constructor(options?: PrecacheStrategyOptions);
28
- /**
29
- * @private
30
- * @param request A request to run this strategy for.
31
- * @param handler The event that triggered the request.
32
- * @returns
33
- */
34
- _handle(request: Request, handler: StrategyHandler): Promise<Response>;
35
- _handleFetch(request: Request, handler: StrategyHandler): Promise<Response>;
36
- _handleInstall(request: Request, handler: StrategyHandler): Promise<Response>;
37
- /**
38
- * This method is complex, as there a number of things to account for:
39
- *
40
- * The `plugins` array can be set at construction, and/or it might be added to
41
- * to at any time before the strategy is used.
42
- *
43
- * At the time the strategy is used (i.e. during an `install` event), there
44
- * needs to be at least one plugin that implements `cacheWillUpdate` in the
45
- * array, other than `copyRedirectedCacheableResponsesPlugin`.
46
- *
47
- * - If this method is called and there are no suitable `cacheWillUpdate`
48
- * plugins, we need to add `defaultPrecacheCacheabilityPlugin`.
49
- *
50
- * - If this method is called and there is exactly one `cacheWillUpdate`, then
51
- * we don't have to do anything (this might be a previously added
52
- * `defaultPrecacheCacheabilityPlugin`, or it might be a custom plugin).
53
- *
54
- * - If this method is called and there is more than one `cacheWillUpdate`,
55
- * then we need to check if one is `defaultPrecacheCacheabilityPlugin`. If so,
56
- * we need to remove it. (This situation is unlikely, but it could happen if
57
- * the strategy is used multiple times, the first without a `cacheWillUpdate`,
58
- * and then later on after manually adding a custom `cacheWillUpdate`.)
59
- *
60
- * See https://github.com/GoogleChrome/workbox/issues/2737 for more context.
61
- *
62
- * @private
63
- */
64
- _useDefaultCacheabilityPluginIfNeeded(): void;
65
- }
66
- export { PrecacheStrategy };
67
- //# sourceMappingURL=PrecacheStrategy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrecacheStrategy.d.ts","sourceRoot":"","sources":["../src/PrecacheStrategy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,UAAU,uBAAwB,SAAQ,eAAe;IACvD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,cAAM,gBAAiB,SAAQ,QAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAU;IAE7C,MAAM,CAAC,QAAQ,CAAC,iCAAiC,EAAE,aAAa,CAQ9D;IAEF,MAAM,CAAC,QAAQ,CAAC,sCAAsC,EAAE,aAAa,CAInE;IAEF;;OAEG;gBACS,OAAO,GAAE,uBAA4B;IAajD;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBtE,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAwE3E,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAoBnF;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,qCAAqC,IAAI,IAAI;CA4B9C;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
package/dist/_types.d.ts DELETED
@@ -1,37 +0,0 @@
1
- export interface InstallResult {
2
- updatedURLs: string[];
3
- notUpdatedURLs: string[];
4
- }
5
- export interface CleanupResult {
6
- deletedCacheRequests: string[];
7
- }
8
- export declare interface PrecacheEntry {
9
- integrity?: string;
10
- url: string;
11
- revision?: string | null;
12
- }
13
- export interface PrecacheRouteOptions {
14
- /**
15
- * The `directoryIndex` will check cache entries for a URL ending with '/'
16
- * to see if there is a hit when appending the `directoryIndex` value.
17
- */
18
- directoryIndex?: string | null;
19
- /**
20
- * An array of RegExp's to remove search params when looking for a cache match.
21
- */
22
- ignoreURLParametersMatching?: RegExp[];
23
- /**
24
- * The `cleanURLs` option will check the cache for the URL with a `.html` added
25
- * to the end of the end.
26
- */
27
- cleanURLs?: boolean;
28
- /**
29
- * This is a function that should take a URL and return an array of
30
- * alternative URLs that should be checked for precache matches.
31
- */
32
- urlManipulation?: urlManipulation;
33
- }
34
- export type urlManipulation = ({ url }: {
35
- url: URL;
36
- }) => URL[];
37
- //# sourceMappingURL=_types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../src/_types.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,CAAC,OAAO,WAAW,aAAa;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;OAEG;IACH,2BAA2B,CAAC,EAAE,MAAM,EAAE,CAAC;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,GAAG,CAAA;CAAE,KAAK,GAAG,EAAE,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { SerwistPlugin } from "@serwist/core";
2
- /**
3
- * Adds plugins to the precaching strategy.
4
- *
5
- * @param plugins
6
- */
7
- declare function addPlugins(plugins: SerwistPlugin[]): void;
8
- export { addPlugins };
9
- //# sourceMappingURL=addPlugins.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addPlugins.d.ts","sourceRoot":"","sources":["../src/addPlugins.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD;;;;GAIG;AACH,iBAAS,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,IAAI,CAGlD;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,15 +0,0 @@
1
- import type { PrecacheRouteOptions } from "./_types.js";
2
- /**
3
- * Add a `fetch` listener to the service worker that will
4
- * respond to
5
- * [network requests](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests)
6
- * with precached assets.
7
- *
8
- * Requests for assets that aren't precached, the `FetchEvent` will not be
9
- * responded to, allowing the event to fall through to other `fetch` event
10
- * listeners.
11
- *
12
- * @param options See the `@serwist/precaching.PrecacheRoute` options.
13
- */
14
- export declare const addRoute: (options?: PrecacheRouteOptions) => void;
15
- //# sourceMappingURL=addRoute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addRoute.d.ts","sourceRoot":"","sources":["../src/addRoute.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,aAAc,oBAAoB,KAAG,IAKzD,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * Adds an `activate` event listener which will clean up incompatible
3
- * precaches that were created by older versions of Serwist.
4
- */
5
- export declare const cleanupOutdatedCaches: () => void;
6
- //# sourceMappingURL=cleanupOutdatedCaches.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cleanupOutdatedCaches.d.ts","sourceRoot":"","sources":["../src/cleanupOutdatedCaches.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,IAcxC,CAAC"}
@@ -1,17 +0,0 @@
1
- import type { RouteHandlerCallback } from "@serwist/core";
2
- /**
3
- * Helper function that calls `PrecacheController#createHandlerBoundToURL`
4
- * on the default `PrecacheController` instance.
5
- *
6
- * If you are creating your own `PrecacheController`, then call the
7
- * `PrecacheController#createHandlerBoundToURL` on that instance,
8
- * instead of using this function.
9
- *
10
- * @param url The precached URL which will be used to lookup the
11
- * `Response`.
12
- * @param fallbackToNetwork Whether to attempt to get the
13
- * response from the network if there's a precache miss.
14
- * @return
15
- */
16
- export declare const createHandlerBoundToURL: (url: string) => RouteHandlerCallback;
17
- //# sourceMappingURL=createHandlerBoundToURL.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createHandlerBoundToURL.d.ts","sourceRoot":"","sources":["../src/createHandlerBoundToURL.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,QAAS,MAAM,KAAG,oBAGrD,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Takes in a URL, and returns the corresponding URL that could be used to
3
- * lookup the entry in the precache.
4
- *
5
- * If a relative URL is provided, the location of the service worker file will
6
- * be used as the base.
7
- *
8
- * For precached entries without revision information, the cache key will be the
9
- * same as the original URL.
10
- *
11
- * For precached entries with revision information, the cache key will be the
12
- * original URL with the addition of a query parameter used for keeping track of
13
- * the revision info.
14
- *
15
- * @param url The URL whose cache key to look up.
16
- * @returns The cache key that corresponds to that URL.
17
- */
18
- declare function getCacheKeyForURL(url: string): string | undefined;
19
- export { getCacheKeyForURL };
20
- //# sourceMappingURL=getCacheKeyForURL.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getCacheKeyForURL.d.ts","sourceRoot":"","sources":["../src/getCacheKeyForURL.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1D;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Helper function that calls `PrecacheController#matchPrecache`
3
- * on the default `PrecacheController` instance.
4
- *
5
- * If you are creating your own `PrecacheController`, then call
6
- * `PrecacheController#matchPrecache` on that instance,
7
- * instead of using this function.
8
- *
9
- * @param request The key (without revisioning parameters)
10
- * to look up in the precache.
11
- * @returns
12
- */
13
- declare function matchPrecache(request: string | Request): Promise<Response | undefined>;
14
- export { matchPrecache };
15
- //# sourceMappingURL=matchPrecache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"matchPrecache.d.ts","sourceRoot":"","sources":["../src/matchPrecache.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;GAWG;AACH,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAG/E;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,19 +0,0 @@
1
- import type { PrecacheEntry } from "./_types.js";
2
- /**
3
- * Adds items to the precache list, removing any duplicates and
4
- * stores the files in the precache cache when the service
5
- * worker installs.
6
- *
7
- * This method can be called multiple times.
8
- *
9
- * Please note: This method **will not** serve any of the cached files for you.
10
- * It only precaches files. To respond to a network request you call
11
- * `@serwist/precaching.addRoute`.
12
- *
13
- * If you have a single array of files to precache, you can just call
14
- * `@serwist/precaching.precacheAndRoute`.
15
- *
16
- * @param entries Array of entries to precache.
17
- */
18
- export declare const precache: (entries: (PrecacheEntry | string)[]) => void;
19
- //# sourceMappingURL=precache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"precache.d.ts","sourceRoot":"","sources":["../src/precache.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,YAAa,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,KAAG,IAG9D,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { PrecacheEntry, PrecacheRouteOptions } from "./_types.js";
2
- /**
3
- * This method will add entries to the precache list and add a route to
4
- * respond to fetch events.
5
- *
6
- * This is a convenience method that will call
7
- * `@serwist/precaching.precache` and
8
- * `@serwist/precaching.addRoute` in a single call.
9
- *
10
- * @param entries Array of entries to precache.
11
- * @param options See the `@serwist/precaching.PrecacheRoute` options.
12
- */
13
- export declare const precacheAndRoute: (entries: (PrecacheEntry | string)[], options?: PrecacheRouteOptions) => void;
14
- //# sourceMappingURL=precacheAndRoute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"precacheAndRoute.d.ts","sourceRoot":"","sources":["../src/precacheAndRoute.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIvE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,YAAa,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,YAAY,oBAAoB,KAAG,IAGtG,CAAC"}
@@ -1,17 +0,0 @@
1
- import type { SerwistPlugin } from "@serwist/core";
2
- import type { PrecacheController } from "../PrecacheController.js";
3
- /**
4
- * A plugin, designed to be used with PrecacheController, to translate URLs into
5
- * the corresponding cache key, based on the current revision info.
6
- *
7
- * @private
8
- */
9
- declare class PrecacheCacheKeyPlugin implements SerwistPlugin {
10
- private readonly _precacheController;
11
- constructor({ precacheController }: {
12
- precacheController: PrecacheController;
13
- });
14
- cacheKeyWillBeUsed: SerwistPlugin["cacheKeyWillBeUsed"];
15
- }
16
- export { PrecacheCacheKeyPlugin };
17
- //# sourceMappingURL=PrecacheCacheKeyPlugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrecacheCacheKeyPlugin.d.ts","sourceRoot":"","sources":["../../src/utils/PrecacheCacheKeyPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAA8B,MAAM,eAAe,CAAC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;GAKG;AACH,cAAM,sBAAuB,YAAW,aAAa;IACnD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;gBAE7C,EAAE,kBAAkB,EAAE,EAAE;QAAE,kBAAkB,EAAE,kBAAkB,CAAA;KAAE;IAI9E,kBAAkB,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAOrD;CACH;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1,15 +0,0 @@
1
- import type { SerwistPlugin } from "@serwist/core";
2
- /**
3
- * A plugin, designed to be used with PrecacheController, to determine the
4
- * of assets that were updated (or not updated) during the install event.
5
- *
6
- * @private
7
- */
8
- declare class PrecacheInstallReportPlugin implements SerwistPlugin {
9
- updatedURLs: string[];
10
- notUpdatedURLs: string[];
11
- handlerWillStart: SerwistPlugin["handlerWillStart"];
12
- cachedResponseWillBeUsed: SerwistPlugin["cachedResponseWillBeUsed"];
13
- }
14
- export { PrecacheInstallReportPlugin };
15
- //# sourceMappingURL=PrecacheInstallReportPlugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrecacheInstallReportPlugin.d.ts","sourceRoot":"","sources":["../../src/utils/PrecacheInstallReportPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAA8B,MAAM,eAAe,CAAC;AAE/E;;;;;GAKG;AACH,cAAM,2BAA4B,YAAW,aAAa;IACxD,WAAW,EAAE,MAAM,EAAE,CAAM;IAC3B,cAAc,EAAE,MAAM,EAAE,CAAM;IAE9B,gBAAgB,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAKjD;IAEF,wBAAwB,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAkBjE;CACH;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
@@ -1,16 +0,0 @@
1
- import type { PrecacheEntry } from "../_types.js";
2
- interface CacheKey {
3
- cacheKey: string;
4
- url: string;
5
- }
6
- /**
7
- * Converts a manifest entry into a versioned URL suitable for precaching.
8
- *
9
- * @param entry
10
- * @returns A URL with versioning info.
11
- *
12
- * @private
13
- */
14
- export declare function createCacheKey(entry: PrecacheEntry | string): CacheKey;
15
- export {};
16
- //# sourceMappingURL=createCacheKey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createCacheKey.d.ts","sourceRoot":"","sources":["../../src/utils/createCacheKey.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,UAAU,QAAQ;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAKD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,QAAQ,CAuCtE"}
@@ -1,18 +0,0 @@
1
- /**
2
- * Cleans up incompatible precaches that were created by older versions of
3
- * Serwist, by a service worker registered under the current scope.
4
- *
5
- * This is meant to be called as part of the `activate` event.
6
- *
7
- * This should be safe to use as long as you don't include `substringToFind`
8
- * (defaulting to `-precache-`) in your non-precache cache names.
9
- *
10
- * @param currentPrecacheName The cache name currently in use for
11
- * precaching. This cache won't be deleted.
12
- * @param substringToFind Cache names which include this
13
- * substring will be deleted (excluding `currentPrecacheName`).
14
- * @returns A list of all the cache names that were deleted.
15
- * @private
16
- */
17
- export declare const deleteOutdatedCaches: (currentPrecacheName: string, substringToFind?: string) => Promise<string[]>;
18
- //# sourceMappingURL=deleteOutdatedCaches.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deleteOutdatedCaches.d.ts","sourceRoot":"","sources":["../../src/utils/deleteOutdatedCaches.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,wBAA+B,MAAM,oBAAmB,MAAM,KAAuB,QAAQ,MAAM,EAAE,CAUrI,CAAC"}