@serwist/strategies 9.0.0-preview.3 → 9.0.0-preview.5

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.
@@ -1,7 +1,7 @@
1
1
  import { Strategy } from "./Strategy.js";
2
2
  import type { StrategyHandler } from "./StrategyHandler.js";
3
3
  /**
4
- * An implementation of a [cache first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-first-falling-back-to-network)
4
+ * An implementation of the [cache first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-first-falling-back-to-network)
5
5
  * request strategy.
6
6
  *
7
7
  * A cache first strategy is useful for assets that have been revisioned,
@@ -11,7 +11,7 @@ import type { StrategyHandler } from "./StrategyHandler.js";
11
11
  * If the network request fails, and there is no cache match, this will throw
12
12
  * a `SerwistError` exception.
13
13
  */
14
- declare class CacheFirst extends Strategy {
14
+ export declare class CacheFirst extends Strategy {
15
15
  /**
16
16
  * @private
17
17
  * @param request A request to run this strategy for.
@@ -20,5 +20,4 @@ declare class CacheFirst extends Strategy {
20
20
  */
21
21
  _handle(request: Request, handler: StrategyHandler): Promise<Response>;
22
22
  }
23
- export { CacheFirst };
24
23
  //# sourceMappingURL=CacheFirst.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CacheFirst.d.ts","sourceRoot":"","sources":["../src/CacheFirst.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;;;;;;;;GAUG;AACH,cAAM,UAAW,SAAQ,QAAQ;IAC/B;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CAsD7E;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"CacheFirst.d.ts","sourceRoot":"","sources":["../src/CacheFirst.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;;;;;;;;GAUG;AACH,qBAAa,UAAW,SAAQ,QAAQ;IACtC;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CAsD7E"}
@@ -1,14 +1,14 @@
1
1
  import { Strategy } from "./Strategy.js";
2
2
  import type { StrategyHandler } from "./StrategyHandler.js";
3
3
  /**
4
- * An implementation of a [cache only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-only)
4
+ * An implementation of the [cache only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-only)
5
5
  * request strategy.
6
6
  *
7
7
  * This class is useful if you want to take advantage of any Serwist plugin.
8
8
  *
9
9
  * If there is no cache match, this will throw a `SerwistError` exception.
10
10
  */
11
- declare class CacheOnly extends Strategy {
11
+ export declare class CacheOnly extends Strategy {
12
12
  /**
13
13
  * @private
14
14
  * @param request A request to run this strategy for.
@@ -17,5 +17,4 @@ declare class CacheOnly extends Strategy {
17
17
  */
18
18
  _handle(request: Request, handler: StrategyHandler): Promise<Response>;
19
19
  }
20
- export { CacheOnly };
21
20
  //# sourceMappingURL=CacheOnly.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CacheOnly.d.ts","sourceRoot":"","sources":["../src/CacheOnly.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;;;;;GAOG;AACH,cAAM,SAAU,SAAQ,QAAQ;IAC9B;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CA4B7E;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"CacheOnly.d.ts","sourceRoot":"","sources":["../src/CacheOnly.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;;;;;GAOG;AACH,qBAAa,SAAU,SAAQ,QAAQ;IACrC;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CA4B7E"}
@@ -7,21 +7,20 @@ export interface NetworkFirstOptions extends StrategyOptions {
7
7
  */
8
8
  networkTimeoutSeconds?: number;
9
9
  }
10
- /**
11
- * An implementation of a [network first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-first-falling-back-to-cache)
12
- * request strategy.
13
- *
14
- * By default, this strategy will cache responses with a 200 status code as
15
- * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
16
- * Opaque responses are are cross-origin requests where the response doesn't
17
- * support [CORS](https://enable-cors.org/).
18
- *
19
- * If the network request fails, and there is no cache match, this will throw
20
- * a `SerwistError` exception.
21
- */
22
10
  export declare class NetworkFirst extends Strategy {
23
11
  private readonly _networkTimeoutSeconds;
24
12
  /**
13
+ * An implementation of the [network first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-first-falling-back-to-cache)
14
+ * request strategy.
15
+ *
16
+ * By default, this strategy will cache responses with a 200 status code as
17
+ * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
18
+ * Opaque responses are are cross-origin requests where the response doesn't
19
+ * support [CORS](https://enable-cors.org/).
20
+ *
21
+ * If the network request fails, and there is no cache match, this will throw
22
+ * a `SerwistError` exception.
23
+ *
25
24
  * @param options
26
25
  * This option can be used to combat
27
26
  * "[lie-fi](https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi)"
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkFirst.d.ts","sourceRoot":"","sources":["../src/NetworkFirst.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,YAAa,SAAQ,QAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAEhD;;;;;OAKG;gBACS,OAAO,GAAE,mBAAwB;IAsB7C;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgE5E;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;;;;;;;;OASG;IACG,kBAAkB,CAAC,EACvB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,GACR,EAAE;QACD,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,GAAG,EAAE,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,eAAe,CAAC;KAC1B,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;CAqClC"}
1
+ {"version":3,"file":"NetworkFirst.d.ts","sourceRoot":"","sources":["../src/NetworkFirst.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,MAAM,WAAW,mBAAoB,SAAQ,eAAe;IAC1D;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,qBAAa,YAAa,SAAQ,QAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAEhD;;;;;;;;;;;;;;;;OAgBG;gBACS,OAAO,GAAE,mBAAwB;IAsB7C;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgE5E;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA8B1B;;;;;;;;;OASG;IACG,kBAAkB,CAAC,EACvB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAO,GACR,EAAE;QACD,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,GAAG,EAAE,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,eAAe,CAAC;KAC1B,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;CAqClC"}
@@ -1,23 +1,22 @@
1
1
  import type { StrategyOptions } from "./Strategy.js";
2
2
  import { Strategy } from "./Strategy.js";
3
3
  import type { StrategyHandler } from "./StrategyHandler.js";
4
- interface NetworkOnlyOptions extends Omit<StrategyOptions, "cacheName" | "matchOptions"> {
4
+ export interface NetworkOnlyOptions extends Omit<StrategyOptions, "cacheName" | "matchOptions"> {
5
5
  /**
6
6
  * If set, any network requests that fail to respond within the timeout will result in a network error.
7
7
  */
8
8
  networkTimeoutSeconds?: number;
9
9
  }
10
- /**
11
- * An implementation of a [network only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-only)
12
- * request strategy.
13
- *
14
- * This class is useful if you want to take advantage of any Serwist plugin.
15
- *
16
- * If the network request fails, this will throw a `SerwistError` exception.
17
- */
18
- declare class NetworkOnly extends Strategy {
10
+ export declare class NetworkOnly extends Strategy {
19
11
  private readonly _networkTimeoutSeconds;
20
12
  /**
13
+ * An implementation of the [network only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-only)
14
+ * request strategy.
15
+ *
16
+ * This class is useful if you want to take advantage of any Serwist plugin.
17
+ *
18
+ * If the network request fails, this will throw a `SerwistError` exception.
19
+ *
21
20
  * @param options
22
21
  */
23
22
  constructor(options?: NetworkOnlyOptions);
@@ -29,6 +28,4 @@ declare class NetworkOnly extends Strategy {
29
28
  */
30
29
  _handle(request: Request, handler: StrategyHandler): Promise<Response>;
31
30
  }
32
- export { NetworkOnly };
33
- export type { NetworkOnlyOptions };
34
31
  //# sourceMappingURL=NetworkOnly.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkOnly.d.ts","sourceRoot":"","sources":["../src/NetworkOnly.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,UAAU,kBAAmB,SAAQ,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,cAAc,CAAC;IACtF;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,cAAM,WAAY,SAAQ,QAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAEhD;;OAEG;gBACS,OAAO,GAAE,kBAAuB;IAM5C;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CA+C7E;AAED,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"NetworkOnly.d.ts","sourceRoot":"","sources":["../src/NetworkOnly.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,cAAc,CAAC;IAC7F;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,qBAAa,WAAY,SAAQ,QAAQ;IACvC,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAEhD;;;;;;;;;OASG;gBACS,OAAO,GAAE,kBAAuB;IAM5C;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CA+C7E"}
@@ -1,26 +1,25 @@
1
1
  import type { StrategyOptions } from "./Strategy.js";
2
2
  import { Strategy } from "./Strategy.js";
3
3
  import type { StrategyHandler } from "./StrategyHandler.js";
4
- /**
5
- * An implementation of a
6
- * [stale-while-revalidate](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#stale-while-revalidate)
7
- * request strategy.
8
- *
9
- * Resources are requested from both the cache and the network in parallel.
10
- * The strategy will respond with the cached version if available, otherwise
11
- * wait for the network response. The cache is updated with the network response
12
- * with each successful request.
13
- *
14
- * By default, this strategy will cache responses with a 200 status code as
15
- * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
16
- * Opaque responses are cross-origin requests where the response doesn't
17
- * support [CORS](https://enable-cors.org/).
18
- *
19
- * If the network request fails, and there is no cache match, this will throw
20
- * a `SerwistError` exception.
21
- */
22
- declare class StaleWhileRevalidate extends Strategy {
4
+ export declare class StaleWhileRevalidate extends Strategy {
23
5
  /**
6
+ * An implementation of the
7
+ * [stale-while-revalidate](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#stale-while-revalidate)
8
+ * request strategy.
9
+ *
10
+ * Resources are requested from both the cache and the network in parallel.
11
+ * The strategy will respond with the cached version if available, otherwise
12
+ * wait for the network response. The cache is updated with the network response
13
+ * with each successful request.
14
+ *
15
+ * By default, this strategy will cache responses with a 200 status code as
16
+ * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
17
+ * Opaque responses are cross-origin requests where the response doesn't
18
+ * support [CORS](https://enable-cors.org/).
19
+ *
20
+ * If the network request fails, and there is no cache match, this will throw
21
+ * a `SerwistError` exception.
22
+ *
24
23
  * @param options
25
24
  */
26
25
  constructor(options?: StrategyOptions);
@@ -32,5 +31,4 @@ declare class StaleWhileRevalidate extends Strategy {
32
31
  */
33
32
  _handle(request: Request, handler: StrategyHandler): Promise<Response>;
34
33
  }
35
- export { StaleWhileRevalidate };
36
34
  //# sourceMappingURL=StaleWhileRevalidate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StaleWhileRevalidate.d.ts","sourceRoot":"","sources":["../src/StaleWhileRevalidate.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAM,oBAAqB,SAAQ,QAAQ;IACzC;;OAEG;gBACS,OAAO,GAAE,eAAoB;IAUzC;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CAsD7E;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
1
+ {"version":3,"file":"StaleWhileRevalidate.d.ts","sourceRoot":"","sources":["../src/StaleWhileRevalidate.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D,qBAAa,oBAAqB,SAAQ,QAAQ;IAChD;;;;;;;;;;;;;;;;;;;OAmBG;gBACS,OAAO,GAAE,eAAoB;IAUzC;;;;;OAKG;IACG,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CAsD7E"}
@@ -27,7 +27,7 @@ export interface StrategyOptions {
27
27
  * fetching and cache logic, which will ensure all relevant cache, cache options,
28
28
  * fetch options and plugins are used (per the current strategy instance).
29
29
  */
30
- declare abstract class Strategy implements RouteHandlerObject {
30
+ export declare abstract class Strategy implements RouteHandlerObject {
31
31
  cacheName: string;
32
32
  plugins: SerwistPlugin[];
33
33
  fetchOptions?: RequestInit;
@@ -80,5 +80,4 @@ declare abstract class Strategy implements RouteHandlerObject {
80
80
  _getResponse(handler: StrategyHandler, request: Request, event: ExtendableEvent): Promise<Response>;
81
81
  _awaitComplete(responseDone: Promise<Response>, handler: StrategyHandler, request: Request, event: ExtendableEvent): Promise<void>;
82
82
  }
83
- export { Strategy };
84
83
  //# sourceMappingURL=Strategy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Strategy.d.ts","sourceRoot":"","sources":["../src/Strategy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG/F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAClC;AAED;;;;;GAKG;AACH,uBAAe,QAAS,YAAW,kBAAkB;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAEjC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IAErG;;;;;;;;;OASG;gBACS,OAAO,GAAE,eAAoB;IAOzC;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKvE;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,sBAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAsBrF,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAyCnG,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAqCzI;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"Strategy.d.ts","sourceRoot":"","sources":["../src/Strategy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG/F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;;OAGG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAClC;AAED;;;;;GAKG;AACH,8BAAsB,QAAS,YAAW,kBAAkB;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAEjC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IAErG;;;;;;;;;OASG;gBACS,OAAO,GAAE,eAAoB;IAOzC;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,sBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKvE;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,sBAAsB,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAsBrF,YAAY,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAyCnG,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAqCzI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/strategies",
3
- "version": "9.0.0-preview.3",
3
+ "version": "9.0.0-preview.5",
4
4
  "type": "module",
5
5
  "description": "A service worker helper library implementing common caching strategies.",
6
6
  "files": [
@@ -30,12 +30,12 @@
30
30
  "./package.json": "./package.json"
31
31
  },
32
32
  "dependencies": {
33
- "@serwist/core": "9.0.0-preview.3"
33
+ "@serwist/core": "9.0.0-preview.5"
34
34
  },
35
35
  "devDependencies": {
36
36
  "rollup": "4.9.6",
37
37
  "typescript": "5.4.0-dev.20240206",
38
- "@serwist/constants": "9.0.0-preview.3"
38
+ "@serwist/constants": "9.0.0-preview.5"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "typescript": ">=5.0.0"
package/src/CacheFirst.ts CHANGED
@@ -13,7 +13,7 @@ import type { StrategyHandler } from "./StrategyHandler.js";
13
13
  import { messages } from "./utils/messages.js";
14
14
 
15
15
  /**
16
- * An implementation of a [cache first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-first-falling-back-to-network)
16
+ * An implementation of the [cache first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-first-falling-back-to-network)
17
17
  * request strategy.
18
18
  *
19
19
  * A cache first strategy is useful for assets that have been revisioned,
@@ -23,7 +23,7 @@ import { messages } from "./utils/messages.js";
23
23
  * If the network request fails, and there is no cache match, this will throw
24
24
  * a `SerwistError` exception.
25
25
  */
26
- class CacheFirst extends Strategy {
26
+ export class CacheFirst extends Strategy {
27
27
  /**
28
28
  * @private
29
29
  * @param request A request to run this strategy for.
@@ -85,5 +85,3 @@ class CacheFirst extends Strategy {
85
85
  return response;
86
86
  }
87
87
  }
88
-
89
- export { CacheFirst };
package/src/CacheOnly.ts CHANGED
@@ -13,14 +13,14 @@ import type { StrategyHandler } from "./StrategyHandler.js";
13
13
  import { messages } from "./utils/messages.js";
14
14
 
15
15
  /**
16
- * An implementation of a [cache only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-only)
16
+ * An implementation of the [cache only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#cache-only)
17
17
  * request strategy.
18
18
  *
19
19
  * This class is useful if you want to take advantage of any Serwist plugin.
20
20
  *
21
21
  * If there is no cache match, this will throw a `SerwistError` exception.
22
22
  */
23
- class CacheOnly extends Strategy {
23
+ export class CacheOnly extends Strategy {
24
24
  /**
25
25
  * @private
26
26
  * @param request A request to run this strategy for.
@@ -56,5 +56,3 @@ class CacheOnly extends Strategy {
56
56
  return response;
57
57
  }
58
58
  }
59
-
60
- export { CacheOnly };
@@ -21,22 +21,21 @@ export interface NetworkFirstOptions extends StrategyOptions {
21
21
  networkTimeoutSeconds?: number;
22
22
  }
23
23
 
24
- /**
25
- * An implementation of a [network first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-first-falling-back-to-cache)
26
- * request strategy.
27
- *
28
- * By default, this strategy will cache responses with a 200 status code as
29
- * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
30
- * Opaque responses are are cross-origin requests where the response doesn't
31
- * support [CORS](https://enable-cors.org/).
32
- *
33
- * If the network request fails, and there is no cache match, this will throw
34
- * a `SerwistError` exception.
35
- */
36
24
  export class NetworkFirst extends Strategy {
37
25
  private readonly _networkTimeoutSeconds: number;
38
26
 
39
27
  /**
28
+ * An implementation of the [network first](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-first-falling-back-to-cache)
29
+ * request strategy.
30
+ *
31
+ * By default, this strategy will cache responses with a 200 status code as
32
+ * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
33
+ * Opaque responses are are cross-origin requests where the response doesn't
34
+ * support [CORS](https://enable-cors.org/).
35
+ *
36
+ * If the network request fails, and there is no cache match, this will throw
37
+ * a `SerwistError` exception.
38
+ *
40
39
  * @param options
41
40
  * This option can be used to combat
42
41
  * "[lie-fi](https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi)"
@@ -13,25 +13,24 @@ import { Strategy } from "./Strategy.js";
13
13
  import type { StrategyHandler } from "./StrategyHandler.js";
14
14
  import { messages } from "./utils/messages.js";
15
15
 
16
- interface NetworkOnlyOptions extends Omit<StrategyOptions, "cacheName" | "matchOptions"> {
16
+ export interface NetworkOnlyOptions extends Omit<StrategyOptions, "cacheName" | "matchOptions"> {
17
17
  /**
18
18
  * If set, any network requests that fail to respond within the timeout will result in a network error.
19
19
  */
20
20
  networkTimeoutSeconds?: number;
21
21
  }
22
22
 
23
- /**
24
- * An implementation of a [network only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-only)
25
- * request strategy.
26
- *
27
- * This class is useful if you want to take advantage of any Serwist plugin.
28
- *
29
- * If the network request fails, this will throw a `SerwistError` exception.
30
- */
31
- class NetworkOnly extends Strategy {
23
+ export class NetworkOnly extends Strategy {
32
24
  private readonly _networkTimeoutSeconds: number;
33
25
 
34
26
  /**
27
+ * An implementation of the [network only](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#network-only)
28
+ * request strategy.
29
+ *
30
+ * This class is useful if you want to take advantage of any Serwist plugin.
31
+ *
32
+ * If the network request fails, this will throw a `SerwistError` exception.
33
+ *
35
34
  * @param options
36
35
  */
37
36
  constructor(options: NetworkOnlyOptions = {}) {
@@ -94,6 +93,3 @@ class NetworkOnly extends Strategy {
94
93
  return response;
95
94
  }
96
95
  }
97
-
98
- export { NetworkOnly };
99
- export type { NetworkOnlyOptions };
@@ -14,26 +14,25 @@ import type { StrategyHandler } from "./StrategyHandler.js";
14
14
  import { cacheOkAndOpaquePlugin } from "./plugins/cacheOkAndOpaquePlugin.js";
15
15
  import { messages } from "./utils/messages.js";
16
16
 
17
- /**
18
- * An implementation of a
19
- * [stale-while-revalidate](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#stale-while-revalidate)
20
- * request strategy.
21
- *
22
- * Resources are requested from both the cache and the network in parallel.
23
- * The strategy will respond with the cached version if available, otherwise
24
- * wait for the network response. The cache is updated with the network response
25
- * with each successful request.
26
- *
27
- * By default, this strategy will cache responses with a 200 status code as
28
- * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
29
- * Opaque responses are cross-origin requests where the response doesn't
30
- * support [CORS](https://enable-cors.org/).
31
- *
32
- * If the network request fails, and there is no cache match, this will throw
33
- * a `SerwistError` exception.
34
- */
35
- class StaleWhileRevalidate extends Strategy {
17
+ export class StaleWhileRevalidate extends Strategy {
36
18
  /**
19
+ * An implementation of the
20
+ * [stale-while-revalidate](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#stale-while-revalidate)
21
+ * request strategy.
22
+ *
23
+ * Resources are requested from both the cache and the network in parallel.
24
+ * The strategy will respond with the cached version if available, otherwise
25
+ * wait for the network response. The cache is updated with the network response
26
+ * with each successful request.
27
+ *
28
+ * By default, this strategy will cache responses with a 200 status code as
29
+ * well as [opaque responses](https://developer.chrome.com/docs/workbox/caching-resources-during-runtime/#opaque-responses).
30
+ * Opaque responses are cross-origin requests where the response doesn't
31
+ * support [CORS](https://enable-cors.org/).
32
+ *
33
+ * If the network request fails, and there is no cache match, this will throw
34
+ * a `SerwistError` exception.
35
+ *
37
36
  * @param options
38
37
  */
39
38
  constructor(options: StrategyOptions = {}) {
@@ -107,5 +106,3 @@ class StaleWhileRevalidate extends Strategy {
107
106
  return response;
108
107
  }
109
108
  }
110
-
111
- export { StaleWhileRevalidate };
package/src/Strategy.ts CHANGED
@@ -39,7 +39,7 @@ export interface StrategyOptions {
39
39
  * fetching and cache logic, which will ensure all relevant cache, cache options,
40
40
  * fetch options and plugins are used (per the current strategy instance).
41
41
  */
42
- abstract class Strategy implements RouteHandlerObject {
42
+ export abstract class Strategy implements RouteHandlerObject {
43
43
  cacheName: string;
44
44
  plugins: SerwistPlugin[];
45
45
  fetchOptions?: RequestInit;
@@ -201,5 +201,3 @@ abstract class Strategy implements RouteHandlerObject {
201
201
  }
202
202
  }
203
203
  }
204
-
205
- export { Strategy };