@serwist/precaching 9.0.0-preview.2 → 9.0.0-preview.20

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 -24
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -533
  4. package/package.json +8 -11
  5. package/src/index.ts +5 -36
  6. package/dist/PrecacheController.d.ts +0 -138
  7. package/dist/PrecacheController.d.ts.map +0 -1
  8. package/dist/PrecacheFallbackPlugin.d.ts +0 -44
  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 -16
  19. package/dist/addRoute.d.ts.map +0 -1
  20. package/dist/cleanupOutdatedCaches.d.ts +0 -7
  21. package/dist/cleanupOutdatedCaches.d.ts.map +0 -1
  22. package/dist/createHandlerBoundToURL.d.ts +0 -18
  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 -20
  29. package/dist/precache.d.ts.map +0 -1
  30. package/dist/precacheAndRoute.d.ts +0 -15
  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 -19
  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 -331
  53. package/src/PrecacheFallbackPlugin.ts +0 -61
  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 -33
  59. package/src/cleanupOutdatedCaches.ts +0 -34
  60. package/src/createHandlerBoundToURL.ts +0 -32
  61. package/src/getCacheKeyForURL.ts +0 -33
  62. package/src/matchPrecache.ts +0 -28
  63. package/src/precache.ts +0 -33
  64. package/src/precacheAndRoute.ts +0 -29
  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 -42
  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
@@ -1,138 +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
- /**
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: (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: (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(): 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
@@ -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;AAGpD,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;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,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;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,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;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -1,44 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -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,16 +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
- declare function addRoute(options?: PrecacheRouteOptions): void;
15
- export { addRoute };
16
- //# 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,iBAAS,QAAQ,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAKtD;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,7 +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
- declare function cleanupOutdatedCaches(): void;
6
- export { cleanupOutdatedCaches };
7
- //# sourceMappingURL=cleanupOutdatedCaches.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,18 +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
- declare function createHandlerBoundToURL(url: string): RouteHandlerCallback;
17
- export { createHandlerBoundToURL };
18
- //# 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,iBAAS,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAGlE;AAED,OAAO,EAAE,uBAAuB,EAAE,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,20 +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
- declare function precache(entries: (PrecacheEntry | string)[]): void;
19
- export { precache };
20
- //# 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,iBAAS,QAAQ,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI,CAG3D;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,15 +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
- declare function precacheAndRoute(entries: (PrecacheEntry | string)[], options?: PrecacheRouteOptions): void;
14
- export { precacheAndRoute };
15
- //# 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,iBAAS,gBAAgB,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAGnG;AAED,OAAO,EAAE,gBAAgB,EAAE,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,19 +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
- declare const deleteOutdatedCaches: (currentPrecacheName: string, substringToFind?: string) => Promise<string[]>;
18
- export { deleteOutdatedCaches };
19
- //# 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,QAAA,MAAM,oBAAoB,wBAA+B,MAAM,oBAAmB,MAAM,KAAuB,QAAQ,MAAM,EAAE,CAU9H,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -1,12 +0,0 @@
1
- import type { PrecacheRouteOptions } from "../_types.js";
2
- /**
3
- * Generator function that yields possible variations on the original URL to
4
- * check, one at a time.
5
- *
6
- * @param url
7
- * @param options
8
- *
9
- * @private
10
- */
11
- export declare function generateURLVariations(url: string, { ignoreURLParametersMatching, directoryIndex, cleanURLs, urlManipulation, }?: PrecacheRouteOptions): Generator<string, void, unknown>;
12
- //# sourceMappingURL=generateURLVariations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateURLVariations.d.ts","sourceRoot":"","sources":["../../src/utils/generateURLVariations.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGzD;;;;;;;;GAQG;AACH,wBAAiB,qBAAqB,CACpC,GAAG,EAAE,MAAM,EACX,EACE,2BAAmD,EACnD,cAA6B,EAC7B,SAAgB,EAChB,eAAe,GAChB,GAAE,oBAAyB,GAC3B,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CA0BlC"}
@@ -1,14 +0,0 @@
1
- import type { PrecacheRouteOptions } from "../_types.js";
2
- /**
3
- * This function will take the request URL and manipulate it based on the
4
- * configuration options.
5
- *
6
- * @param url
7
- * @param options
8
- * @returns Returns the URL in the cache that matches the request,
9
- * if possible.
10
- *
11
- * @private
12
- */
13
- export declare const getCacheKeyForURL: (url: string, options: PrecacheRouteOptions) => string | undefined;
14
- //# sourceMappingURL=getCacheKeyForURL.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getCacheKeyForURL.d.ts","sourceRoot":"","sources":["../../src/utils/getCacheKeyForURL.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAIzD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,QAAS,MAAM,WAAW,oBAAoB,KAAG,MAAM,GAAG,SAYvF,CAAC"}
@@ -1,7 +0,0 @@
1
- import { PrecacheController } from "../PrecacheController.js";
2
- /**
3
- * @returns
4
- * @private
5
- */
6
- export declare const getOrCreatePrecacheController: () => PrecacheController;
7
- //# sourceMappingURL=getOrCreatePrecacheController.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getOrCreatePrecacheController.d.ts","sourceRoot":"","sources":["../../src/utils/getOrCreatePrecacheController.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI9D;;;GAGG;AACH,eAAO,MAAM,6BAA6B,QAAO,kBAKhD,CAAC"}
@@ -1,6 +0,0 @@
1
- /**
2
- * @param deletedURLs
3
- * @private
4
- */
5
- export declare function printCleanupDetails(deletedURLs: string[]): void;
6
- //# sourceMappingURL=printCleanupDetails.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"printCleanupDetails.d.ts","sourceRoot":"","sources":["../../src/utils/printCleanupDetails.ts"],"names":[],"mappings":"AA0BA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAO/D"}