@serwist/precaching 8.0.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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/PrecacheController.d.ts +138 -0
  4. package/dist/PrecacheController.d.ts.map +1 -0
  5. package/dist/PrecacheFallbackPlugin.d.ts +44 -0
  6. package/dist/PrecacheFallbackPlugin.d.ts.map +1 -0
  7. package/dist/PrecacheRoute.d.ts +20 -0
  8. package/dist/PrecacheRoute.d.ts.map +1 -0
  9. package/dist/PrecacheStrategy.d.ts +67 -0
  10. package/dist/PrecacheStrategy.d.ts.map +1 -0
  11. package/dist/_types.d.ts +37 -0
  12. package/dist/_types.d.ts.map +1 -0
  13. package/dist/addPlugins.d.ts +9 -0
  14. package/dist/addPlugins.d.ts.map +1 -0
  15. package/dist/addRoute.d.ts +16 -0
  16. package/dist/addRoute.d.ts.map +1 -0
  17. package/dist/cleanupOutdatedCaches.d.ts +7 -0
  18. package/dist/cleanupOutdatedCaches.d.ts.map +1 -0
  19. package/dist/createHandlerBoundToURL.d.ts +18 -0
  20. package/dist/createHandlerBoundToURL.d.ts.map +1 -0
  21. package/dist/getCacheKeyForURL.d.ts +20 -0
  22. package/dist/getCacheKeyForURL.d.ts.map +1 -0
  23. package/dist/index.d.ts +25 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +917 -0
  26. package/dist/index.old.cjs +930 -0
  27. package/dist/matchPrecache.d.ts +15 -0
  28. package/dist/matchPrecache.d.ts.map +1 -0
  29. package/dist/precache.d.ts +20 -0
  30. package/dist/precache.d.ts.map +1 -0
  31. package/dist/precacheAndRoute.d.ts +15 -0
  32. package/dist/precacheAndRoute.d.ts.map +1 -0
  33. package/dist/utils/PrecacheCacheKeyPlugin.d.ts +17 -0
  34. package/dist/utils/PrecacheCacheKeyPlugin.d.ts.map +1 -0
  35. package/dist/utils/PrecacheInstallReportPlugin.d.ts +15 -0
  36. package/dist/utils/PrecacheInstallReportPlugin.d.ts.map +1 -0
  37. package/dist/utils/createCacheKey.d.ts +16 -0
  38. package/dist/utils/createCacheKey.d.ts.map +1 -0
  39. package/dist/utils/deleteOutdatedCaches.d.ts +19 -0
  40. package/dist/utils/deleteOutdatedCaches.d.ts.map +1 -0
  41. package/dist/utils/generateURLVariations.d.ts +12 -0
  42. package/dist/utils/generateURLVariations.d.ts.map +1 -0
  43. package/dist/utils/getCacheKeyForURL.d.ts +14 -0
  44. package/dist/utils/getCacheKeyForURL.d.ts.map +1 -0
  45. package/dist/utils/getOrCreatePrecacheController.d.ts +7 -0
  46. package/dist/utils/getOrCreatePrecacheController.d.ts.map +1 -0
  47. package/dist/utils/printCleanupDetails.d.ts +6 -0
  48. package/dist/utils/printCleanupDetails.d.ts.map +1 -0
  49. package/dist/utils/printInstallDetails.d.ts +7 -0
  50. package/dist/utils/printInstallDetails.d.ts.map +1 -0
  51. package/dist/utils/removeIgnoredSearchParams.d.ts +12 -0
  52. package/dist/utils/removeIgnoredSearchParams.d.ts.map +1 -0
  53. package/package.json +46 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Google LLC, 2019 ShadowWalker w@weiw.io https://weiw.io, 2023 Serwist
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-precaching
@@ -0,0 +1,138 @@
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
+ /**
21
+ * Performs efficient precaching of assets.
22
+ */
23
+ declare class PrecacheController {
24
+ private _installAndActiveListenersAdded?;
25
+ private readonly _strategy;
26
+ private readonly _urlsToCacheKeys;
27
+ private readonly _urlsToCacheModes;
28
+ private readonly _cacheKeysToIntegrities;
29
+ /**
30
+ * Create a new PrecacheController.
31
+ *
32
+ * @param options
33
+ */
34
+ constructor({ cacheName, plugins, fallbackToNetwork }?: PrecacheControllerOptions);
35
+ /**
36
+ * The strategy created by this controller and
37
+ * used to cache assets and respond to fetch events.
38
+ */
39
+ get strategy(): Strategy;
40
+ /**
41
+ * Adds items to the precache list, removing any duplicates and
42
+ * stores the files in the precache cache when the service
43
+ * worker installs.
44
+ *
45
+ * This method can be called multiple times.
46
+ *
47
+ * @param entries Array of entries to precache.
48
+ */
49
+ precache(entries: Array<PrecacheEntry | string>): void;
50
+ /**
51
+ * This method will add items to the precache list, removing duplicates
52
+ * and ensuring the information is valid.
53
+ *
54
+ * @param entries Array of entries to precache.
55
+ */
56
+ addToCacheList(entries: Array<PrecacheEntry | string>): void;
57
+ /**
58
+ * Precaches new and updated assets. Call this method from the service worker
59
+ * install event.
60
+ *
61
+ * Note: this method calls `event.waitUntil()` for you, so you do not need
62
+ * to call it yourself in your event handlers.
63
+ *
64
+ * @param event
65
+ * @returns
66
+ */
67
+ install(event: ExtendableEvent): Promise<InstallResult>;
68
+ /**
69
+ * Deletes assets that are no longer present in the current precache manifest.
70
+ * Call this method from the service worker activate event.
71
+ *
72
+ * Note: this method calls `event.waitUntil()` for you, so you do not need
73
+ * to call it yourself in your event handlers.
74
+ *
75
+ * @param event
76
+ * @returns
77
+ */
78
+ activate(event: ExtendableEvent): Promise<CleanupResult>;
79
+ /**
80
+ * Returns a mapping of a precached URL to the corresponding cache key, taking
81
+ * into account the revision information for the URL.
82
+ *
83
+ * @returns A URL to cache key mapping.
84
+ */
85
+ getURLsToCacheKeys(): Map<string, string>;
86
+ /**
87
+ * Returns a list of all the URLs that have been precached by the current
88
+ * service worker.
89
+ *
90
+ * @returns The precached URLs.
91
+ */
92
+ getCachedURLs(): Array<string>;
93
+ /**
94
+ * Returns the cache key used for storing a given URL. If that URL is
95
+ * unversioned, like `/index.html', then the cache key will be the original
96
+ * URL with a search parameter appended to it.
97
+ *
98
+ * @param url A URL whose cache key you want to look up.
99
+ * @returns The versioned URL that corresponds to a cache key
100
+ * for the original URL, or undefined if that URL isn't precached.
101
+ */
102
+ getCacheKeyForURL(url: string): string | undefined;
103
+ /**
104
+ * @param url A cache key whose SRI you want to look up.
105
+ * @returns The subresource integrity associated with the cache key,
106
+ * or undefined if it's not set.
107
+ */
108
+ getIntegrityForCacheKey(cacheKey: string): string | undefined;
109
+ /**
110
+ * This acts as a drop-in replacement for
111
+ * [`cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match)
112
+ * with the following differences:
113
+ *
114
+ * - It knows what the name of the precache is, and only checks in that cache.
115
+ * - It allows you to pass in an "original" URL without versioning parameters,
116
+ * and it will automatically look up the correct cache key for the currently
117
+ * active revision of that URL.
118
+ *
119
+ * E.g., `matchPrecache('index.html')` will find the correct precached
120
+ * response for the currently active service worker, even if the actual cache
121
+ * key is `'/index.html?__WB_REVISION__=1234abcd'`.
122
+ *
123
+ * @param request The key (without revisioning parameters)
124
+ * to look up in the precache.
125
+ * @returns
126
+ */
127
+ matchPrecache(request: string | Request): Promise<Response | undefined>;
128
+ /**
129
+ * Returns a function that looks up `url` in the precache (taking into
130
+ * account revision information), and returns the corresponding `Response`.
131
+ *
132
+ * @param url The precached URL which will be used to lookup the response.
133
+ * @return
134
+ */
135
+ createHandlerBoundToURL(url: string): RouteHandlerCallback;
136
+ }
137
+ export { PrecacheController };
138
+ //# sourceMappingURL=PrecacheController.d.ts.map
@@ -0,0 +1 @@
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;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAW/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;CAC7B;AAED;;GAEG;AACH,cAAM,kBAAkB;IACtB,OAAO,CAAC,+BAA+B,CAAC,CAAU;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,GAAE,yBAA8B;IAYjG;;;OAGG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,GAAG,IAAI;IAUtD;;;;;OAKG;IACH,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,GAAG,IAAI;IAyD5D;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAsCvD;;;;;;;;;OASG;IACH,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;IAwBxD;;;;;OAKG;IACH,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAIzC;;;;;OAKG;IACH,aAAa,IAAI,KAAK,CAAC,MAAM,CAAC;IAI9B;;;;;;;;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;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { SerwistPlugin } from "@serwist/core";
2
+ import type { PrecacheController } from "./PrecacheController.js";
3
+ interface PrecacheFallbackPluginOptions {
4
+ /**
5
+ * A precached URL to use as the fallback
6
+ * if the associated strategy can't generate a response.
7
+ */
8
+ fallbackURL: string;
9
+ /**
10
+ * An optional
11
+ * PrecacheController instance. If not provided, the default
12
+ * PrecacheController will be used.
13
+ */
14
+ precacheController?: PrecacheController;
15
+ }
16
+ /**
17
+ * `PrecacheFallbackPlugin` allows you to specify an "offline fallback"
18
+ * response to be used when a given strategy is unable to generate a response.
19
+ *
20
+ * It does this by intercepting the `handlerDidError` plugin callback
21
+ * and returning a precached response, taking the expected revision parameter
22
+ * into account automatically.
23
+ *
24
+ * Unless you explicitly pass in a `PrecacheController` instance to the
25
+ * constructor, the default instance will be used. Generally speaking, most
26
+ * developers will end up using the default.
27
+ */
28
+ declare class PrecacheFallbackPlugin implements SerwistPlugin {
29
+ private readonly _fallbackURL;
30
+ private readonly _precacheController;
31
+ /**
32
+ * Constructs a new PrecacheFallbackPlugin with the associated fallbackURL.
33
+ *
34
+ * @param config
35
+ */
36
+ constructor({ fallbackURL, precacheController }: PrecacheFallbackPluginOptions);
37
+ /**
38
+ * @returns The precache response for the fallback URL.
39
+ * @private
40
+ */
41
+ handlerDidError: SerwistPlugin["handlerDidError"];
42
+ }
43
+ export { PrecacheFallbackPlugin };
44
+ //# sourceMappingURL=PrecacheFallbackPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrecacheFallbackPlugin.d.ts","sourceRoot":"","sources":["../src/PrecacheFallbackPlugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE,UAAU,6BAA6B;IACrC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED;;;;;;;;;;;GAWG;AACH,cAAM,sBAAuB,YAAW,aAAa;IACnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;IAEzD;;;;OAIG;gBACS,EAAE,WAAW,EAAE,kBAAkB,EAAE,EAAE,6BAA6B;IAK9E;;;OAGG;IACH,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAmE;CACrH;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Route } from "@serwist/routing";
2
+ import type { PrecacheRouteOptions } from "./_types.js";
3
+ import type { PrecacheController } from "./PrecacheController.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
@@ -0,0 +1 @@
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,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE;;;;;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"}
@@ -0,0 +1,67 @@
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
@@ -0,0 +1 @@
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;IA0E3E,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"}
@@ -0,0 +1,37 @@
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 URLs ending with '/'
16
+ * to see if there is a hit when appending the `directoryIndex` value.
17
+ */
18
+ directoryIndex?: string;
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
@@ -0,0 +1 @@
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,CAAC;IACxB;;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"}
@@ -0,0 +1,9 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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
+ declare function addRoute(options?: PrecacheRouteOptions): void;
15
+ export { addRoute };
16
+ //# sourceMappingURL=addRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addRoute.d.ts","sourceRoot":"","sources":["../src/addRoute.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAIxD;;;;;;;;;;;GAWG;AACH,iBAAS,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAKtD;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Adds an `activate` event listener which will clean up incompatible
3
+ * precaches that were created by older versions of Serwist.
4
+ */
5
+ declare function cleanupOutdatedCaches(): void;
6
+ export { cleanupOutdatedCaches };
7
+ //# sourceMappingURL=cleanupOutdatedCaches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanupOutdatedCaches.d.ts","sourceRoot":"","sources":["../src/cleanupOutdatedCaches.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,iBAAS,qBAAqB,IAAI,IAAI,CAerC;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,18 @@
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
+ declare function createHandlerBoundToURL(url: string): RouteHandlerCallback;
17
+ export { createHandlerBoundToURL };
18
+ //# sourceMappingURL=createHandlerBoundToURL.d.ts.map
@@ -0,0 +1 @@
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,iBAAS,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAGlE;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,20 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,25 @@
1
+ import { addPlugins } from "./addPlugins.js";
2
+ import { addRoute } from "./addRoute.js";
3
+ import { cleanupOutdatedCaches } from "./cleanupOutdatedCaches.js";
4
+ import { createHandlerBoundToURL } from "./createHandlerBoundToURL.js";
5
+ import { getCacheKeyForURL } from "./getCacheKeyForURL.js";
6
+ import { matchPrecache } from "./matchPrecache.js";
7
+ import { precache } from "./precache.js";
8
+ import { precacheAndRoute } from "./precacheAndRoute.js";
9
+ import { PrecacheController } from "./PrecacheController.js";
10
+ import { PrecacheFallbackPlugin } from "./PrecacheFallbackPlugin.js";
11
+ import { PrecacheRoute } from "./PrecacheRoute.js";
12
+ import { PrecacheStrategy } from "./PrecacheStrategy.js";
13
+ /**
14
+ * Most consumers of this module will want to use the
15
+ * `@serwist/precaching.precacheAndRoute`
16
+ * method to add assets to the cache and respond to network requests with these
17
+ * cached assets.
18
+ *
19
+ * If you require more control over caching and routing, you can use the
20
+ * `@serwist/precaching.PrecacheController`
21
+ * interface.
22
+ */
23
+ export { addPlugins, addRoute, cleanupOutdatedCaches, createHandlerBoundToURL, getCacheKeyForURL, matchPrecache, precache, precacheAndRoute, PrecacheController, PrecacheFallbackPlugin, PrecacheRoute, PrecacheStrategy, };
24
+ export * from "./_types.js";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;GASG;AAEH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,gBAAgB,GACjB,CAAC;AAEF,cAAc,aAAa,CAAC"}