@serwist/recipes 9.0.0-preview.9 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/googleFontsCache.d.ts +6 -2
- package/dist/googleFontsCache.d.ts.map +1 -1
- package/dist/imageCache.d.ts +7 -2
- package/dist/imageCache.d.ts.map +1 -1
- package/dist/index.js +30 -56
- package/dist/offlineFallback.d.ts +6 -1
- package/dist/offlineFallback.d.ts.map +1 -1
- package/dist/pageCache.d.ts +7 -3
- package/dist/pageCache.d.ts.map +1 -1
- package/dist/staticResourceCache.d.ts +7 -3
- package/dist/staticResourceCache.d.ts.map +1 -1
- package/dist/warmStrategyCache.d.ts +2 -3
- package/dist/warmStrategyCache.d.ts.map +1 -1
- package/package.json +6 -11
- package/src/googleFontsCache.ts +16 -18
- package/src/imageCache.ts +18 -17
- package/src/offlineFallback.ts +12 -14
- package/src/pageCache.ts +18 -18
- package/src/staticResourceCache.ts +18 -18
- package/src/warmStrategyCache.ts +3 -5
| @@ -1,4 +1,9 @@ | |
| 1 | 
            +
            import { Serwist } from "serwist";
         | 
| 1 2 | 
             
            export interface GoogleFontCacheOptions {
         | 
| 3 | 
            +
                /**
         | 
| 4 | 
            +
                 * Your `Serwist` instance.
         | 
| 5 | 
            +
                 */
         | 
| 6 | 
            +
                serwist: Serwist;
         | 
| 2 7 | 
             
                /**
         | 
| 3 8 | 
             
                 * Cache prefix for caching stylesheets and webfonts. Defaults to google-fonts.
         | 
| 4 9 | 
             
                 */
         | 
| @@ -17,6 +22,5 @@ export interface GoogleFontCacheOptions { | |
| 17 22 | 
             
             *
         | 
| 18 23 | 
             
             * @param options
         | 
| 19 24 | 
             
             */
         | 
| 20 | 
            -
            declare  | 
| 21 | 
            -
            export { googleFontsCache };
         | 
| 25 | 
            +
            export declare const googleFontsCache: ({ serwist, cachePrefix, maxAgeSeconds, maxEntries, }: GoogleFontCacheOptions) => void;
         | 
| 22 26 | 
             
            //# sourceMappingURL=googleFontsCache.d.ts.map
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"googleFontsCache.d.ts","sourceRoot":"","sources":["../src/googleFontsCache.ts"],"names":[],"mappings":" | 
| 1 | 
            +
            {"version":3,"file":"googleFontsCache.d.ts","sourceRoot":"","sources":["../src/googleFontsCache.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyD,OAAO,EAAwB,MAAM,SAAS,CAAC;AAE/G,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,yDAK1B,sBAAsB,KAAG,IAyB3B,CAAC"}
         | 
    
        package/dist/imageCache.d.ts
    CHANGED
    
    | @@ -1,5 +1,10 @@ | |
| 1 | 
            -
            import type { RouteMatchCallback, SerwistPlugin } from " | 
| 1 | 
            +
            import type { RouteMatchCallback, SerwistPlugin } from "serwist";
         | 
| 2 | 
            +
            import { Serwist } from "serwist";
         | 
| 2 3 | 
             
            export interface ImageCacheOptions {
         | 
| 4 | 
            +
                /**
         | 
| 5 | 
            +
                 * Your `Serwist` instance.
         | 
| 6 | 
            +
                 */
         | 
| 7 | 
            +
                serwist: Serwist;
         | 
| 3 8 | 
             
                /**
         | 
| 4 9 | 
             
                 * Name for cache. Defaults to images.
         | 
| 5 10 | 
             
                 */
         | 
| @@ -30,5 +35,5 @@ export interface ImageCacheOptions { | |
| 30 35 | 
             
             *
         | 
| 31 36 | 
             
             * @param options
         | 
| 32 37 | 
             
             */
         | 
| 33 | 
            -
            export declare const imageCache: ( | 
| 38 | 
            +
            export declare const imageCache: ({ serwist, cacheName, matchCallback, maxAgeSeconds, maxEntries, plugins, warmCache, }: ImageCacheOptions) => void;
         | 
| 34 39 | 
             
            //# sourceMappingURL=imageCache.d.ts.map
         | 
    
        package/dist/imageCache.d.ts.map
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"imageCache.d.ts","sourceRoot":"","sources":["../src/imageCache.ts"],"names":[],"mappings":" | 
| 1 | 
            +
            {"version":3,"file":"imageCache.d.ts","sourceRoot":"","sources":["../src/imageCache.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAA6B,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAyD,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzF,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,0FAQpB,iBAAiB,KAAG,IAwBtB,CAAC"}
         | 
    
        package/dist/index.js
    CHANGED
    
    | @@ -1,19 +1,11 @@ | |
| 1 | 
            -
            import { CacheableResponsePlugin } from ' | 
| 2 | 
            -
            import { ExpirationPlugin } from '@serwist/expiration';
         | 
| 3 | 
            -
            import { registerRoute, setCatchHandler } from '@serwist/routing';
         | 
| 4 | 
            -
            import { StaleWhileRevalidate, CacheFirst, NetworkFirst } from '@serwist/strategies';
         | 
| 5 | 
            -
            import { matchPrecache } from '@serwist/precaching';
         | 
| 1 | 
            +
            import { StaleWhileRevalidate, CacheFirst, CacheableResponsePlugin, ExpirationPlugin, NetworkFirst } from 'serwist';
         | 
| 6 2 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
                 | 
| 9 | 
            -
             | 
| 10 | 
            -
                const maxAgeSeconds = options.maxAgeSeconds || 60 * 60 * 24 * 365;
         | 
| 11 | 
            -
                const maxEntries = options.maxEntries || 30;
         | 
| 12 | 
            -
                registerRoute(({ url })=>url.origin === "https://fonts.googleapis.com", new StaleWhileRevalidate({
         | 
| 13 | 
            -
                    cacheName: sheetCacheName
         | 
| 3 | 
            +
            const googleFontsCache = ({ serwist, cachePrefix = "google-fonts", maxAgeSeconds = 60 * 60 * 24 * 365, maxEntries = 30 })=>{
         | 
| 4 | 
            +
                serwist.registerCapture(({ url })=>url.origin === "https://fonts.googleapis.com", new StaleWhileRevalidate({
         | 
| 5 | 
            +
                    cacheName: `${cachePrefix}-stylesheets`
         | 
| 14 6 | 
             
                }));
         | 
| 15 | 
            -
                 | 
| 16 | 
            -
                    cacheName:  | 
| 7 | 
            +
                serwist.registerCapture(({ url })=>url.origin === "https://fonts.gstatic.com", new CacheFirst({
         | 
| 8 | 
            +
                    cacheName: `${cachePrefix}-webfonts`,
         | 
| 17 9 | 
             
                    plugins: [
         | 
| 18 10 | 
             
                        new CacheableResponsePlugin({
         | 
| 19 11 | 
             
                            statuses: [
         | 
| @@ -27,9 +19,9 @@ function googleFontsCache(options = {}) { | |
| 27 19 | 
             
                        })
         | 
| 28 20 | 
             
                    ]
         | 
| 29 21 | 
             
                }));
         | 
| 30 | 
            -
            }
         | 
| 22 | 
            +
            };
         | 
| 31 23 |  | 
| 32 | 
            -
             | 
| 24 | 
            +
            const warmStrategyCache = (options)=>{
         | 
| 33 25 | 
             
                self.addEventListener("install", (event)=>{
         | 
| 34 26 | 
             
                    const done = options.urls.map((path)=>options.strategy.handleAll({
         | 
| 35 27 | 
             
                            event,
         | 
| @@ -37,15 +29,9 @@ function warmStrategyCache(options) { | |
| 37 29 | 
             
                        })[1]);
         | 
| 38 30 | 
             
                    event.waitUntil(Promise.all(done));
         | 
| 39 31 | 
             
                });
         | 
| 40 | 
            -
            }
         | 
| 32 | 
            +
            };
         | 
| 41 33 |  | 
| 42 | 
            -
            const imageCache = ( | 
| 43 | 
            -
                const defaultMatchCallback = ({ request })=>request.destination === "image";
         | 
| 44 | 
            -
                const cacheName = options.cacheName || "images";
         | 
| 45 | 
            -
                const matchCallback = options.matchCallback || defaultMatchCallback;
         | 
| 46 | 
            -
                const maxAgeSeconds = options.maxAgeSeconds || 30 * 24 * 60 * 60;
         | 
| 47 | 
            -
                const maxEntries = options.maxEntries || 60;
         | 
| 48 | 
            -
                const plugins = options.plugins || [];
         | 
| 34 | 
            +
            const imageCache = ({ serwist, cacheName = "images", matchCallback = ({ request })=>request.destination === "image", maxAgeSeconds = 30 * 24 * 60 * 60, maxEntries = 60, plugins = [], warmCache })=>{
         | 
| 49 35 | 
             
                plugins.push(new CacheableResponsePlugin({
         | 
| 50 36 | 
             
                    statuses: [
         | 
| 51 37 | 
             
                        0,
         | 
| @@ -60,19 +46,16 @@ const imageCache = (options = {})=>{ | |
| 60 46 | 
             
                    cacheName,
         | 
| 61 47 | 
             
                    plugins
         | 
| 62 48 | 
             
                });
         | 
| 63 | 
            -
                 | 
| 64 | 
            -
                if ( | 
| 49 | 
            +
                serwist.registerCapture(matchCallback, strategy);
         | 
| 50 | 
            +
                if (warmCache) {
         | 
| 65 51 | 
             
                    warmStrategyCache({
         | 
| 66 | 
            -
                        urls:  | 
| 52 | 
            +
                        urls: warmCache,
         | 
| 67 53 | 
             
                        strategy
         | 
| 68 54 | 
             
                    });
         | 
| 69 55 | 
             
                }
         | 
| 70 56 | 
             
            };
         | 
| 71 57 |  | 
| 72 | 
            -
            const offlineFallback = ( | 
| 73 | 
            -
                const pageFallback = options.pageFallback || "offline.html";
         | 
| 74 | 
            -
                const imageFallback = options.imageFallback || false;
         | 
| 75 | 
            -
                const fontFallback = options.fontFallback || false;
         | 
| 58 | 
            +
            const offlineFallback = ({ serwist, pageFallback = "offline.html", imageFallback, fontFallback })=>{
         | 
| 76 59 | 
             
                self.addEventListener("install", (event)=>{
         | 
| 77 60 | 
             
                    const files = [
         | 
| 78 61 | 
             
                        pageFallback
         | 
| @@ -89,28 +72,23 @@ const offlineFallback = (options = {})=>{ | |
| 89 72 | 
             
                    const dest = options.request.destination;
         | 
| 90 73 | 
             
                    const cache = await self.caches.open("serwist-offline-fallbacks");
         | 
| 91 74 | 
             
                    if (dest === "document") {
         | 
| 92 | 
            -
                        const match = await matchPrecache(pageFallback) || await cache.match(pageFallback);
         | 
| 75 | 
            +
                        const match = await serwist.matchPrecache(pageFallback) || await cache.match(pageFallback);
         | 
| 93 76 | 
             
                        return match || Response.error();
         | 
| 94 77 | 
             
                    }
         | 
| 95 | 
            -
                    if (dest === "image" && imageFallback !==  | 
| 96 | 
            -
                        const match = await matchPrecache(imageFallback) || await cache.match(imageFallback);
         | 
| 78 | 
            +
                    if (dest === "image" && imageFallback !== undefined) {
         | 
| 79 | 
            +
                        const match = await serwist.matchPrecache(imageFallback) || await cache.match(imageFallback);
         | 
| 97 80 | 
             
                        return match || Response.error();
         | 
| 98 81 | 
             
                    }
         | 
| 99 | 
            -
                    if (dest === "font" && fontFallback !==  | 
| 100 | 
            -
                        const match = await matchPrecache(fontFallback) || await cache.match(fontFallback);
         | 
| 82 | 
            +
                    if (dest === "font" && fontFallback !== undefined) {
         | 
| 83 | 
            +
                        const match = await serwist.matchPrecache(fontFallback) || await cache.match(fontFallback);
         | 
| 101 84 | 
             
                        return match || Response.error();
         | 
| 102 85 | 
             
                    }
         | 
| 103 86 | 
             
                    return Response.error();
         | 
| 104 87 | 
             
                };
         | 
| 105 | 
            -
                setCatchHandler(handler);
         | 
| 88 | 
            +
                serwist.setCatchHandler(handler);
         | 
| 106 89 | 
             
            };
         | 
| 107 90 |  | 
| 108 | 
            -
             | 
| 109 | 
            -
                const defaultMatchCallback = ({ request })=>request.mode === "navigate";
         | 
| 110 | 
            -
                const cacheName = options.cacheName || "pages";
         | 
| 111 | 
            -
                const matchCallback = options.matchCallback || defaultMatchCallback;
         | 
| 112 | 
            -
                const networkTimeoutSeconds = options.networkTimeoutSeconds || 3;
         | 
| 113 | 
            -
                const plugins = options.plugins || [];
         | 
| 91 | 
            +
            const pageCache = ({ serwist, cacheName = "pages", matchCallback = ({ request })=>request.mode === "navigate", networkTimeoutSeconds = 3, plugins = [], warmCache })=>{
         | 
| 114 92 | 
             
                plugins.push(new CacheableResponsePlugin({
         | 
| 115 93 | 
             
                    statuses: [
         | 
| 116 94 | 
             
                        0,
         | 
| @@ -122,20 +100,16 @@ function pageCache(options = {}) { | |
| 122 100 | 
             
                    cacheName,
         | 
| 123 101 | 
             
                    plugins
         | 
| 124 102 | 
             
                });
         | 
| 125 | 
            -
                 | 
| 126 | 
            -
                if ( | 
| 103 | 
            +
                serwist.registerCapture(matchCallback, strategy);
         | 
| 104 | 
            +
                if (warmCache) {
         | 
| 127 105 | 
             
                    warmStrategyCache({
         | 
| 128 | 
            -
                        urls:  | 
| 106 | 
            +
                        urls: warmCache,
         | 
| 129 107 | 
             
                        strategy
         | 
| 130 108 | 
             
                    });
         | 
| 131 109 | 
             
                }
         | 
| 132 | 
            -
            }
         | 
| 110 | 
            +
            };
         | 
| 133 111 |  | 
| 134 | 
            -
             | 
| 135 | 
            -
                const defaultMatchCallback = ({ request })=>request.destination === "style" || request.destination === "script" || request.destination === "worker";
         | 
| 136 | 
            -
                const cacheName = options.cacheName || "static-resources";
         | 
| 137 | 
            -
                const matchCallback = options.matchCallback || defaultMatchCallback;
         | 
| 138 | 
            -
                const plugins = options.plugins || [];
         | 
| 112 | 
            +
            const staticResourceCache = ({ serwist, cacheName = "static-resources", matchCallback = ({ request })=>request.destination === "style" || request.destination === "script" || request.destination === "worker", plugins = [], warmCache })=>{
         | 
| 139 113 | 
             
                plugins.push(new CacheableResponsePlugin({
         | 
| 140 114 | 
             
                    statuses: [
         | 
| 141 115 | 
             
                        0,
         | 
| @@ -146,13 +120,13 @@ function staticResourceCache(options = {}) { | |
| 146 120 | 
             
                    cacheName,
         | 
| 147 121 | 
             
                    plugins
         | 
| 148 122 | 
             
                });
         | 
| 149 | 
            -
                 | 
| 150 | 
            -
                if ( | 
| 123 | 
            +
                serwist.registerCapture(matchCallback, strategy);
         | 
| 124 | 
            +
                if (warmCache) {
         | 
| 151 125 | 
             
                    warmStrategyCache({
         | 
| 152 | 
            -
                        urls:  | 
| 126 | 
            +
                        urls: warmCache,
         | 
| 153 127 | 
             
                        strategy
         | 
| 154 128 | 
             
                    });
         | 
| 155 129 | 
             
                }
         | 
| 156 | 
            -
            }
         | 
| 130 | 
            +
            };
         | 
| 157 131 |  | 
| 158 132 | 
             
            export { googleFontsCache, imageCache, offlineFallback, pageCache, staticResourceCache, warmStrategyCache };
         | 
| @@ -1,4 +1,9 @@ | |
| 1 | 
            +
            import type { Serwist } from "serwist";
         | 
| 1 2 | 
             
            export interface OfflineFallbackOptions {
         | 
| 3 | 
            +
                /**
         | 
| 4 | 
            +
                 * Your `Serwist` instance.
         | 
| 5 | 
            +
                 */
         | 
| 6 | 
            +
                serwist: Serwist;
         | 
| 2 7 | 
             
                /**
         | 
| 3 8 | 
             
                 * Precache name to match for page fallbacks. Defaults to offline.html.
         | 
| 4 9 | 
             
                 */
         | 
| @@ -18,5 +23,5 @@ export interface OfflineFallbackOptions { | |
| 18 23 |  | 
| 19 24 | 
             
             * @param options
         | 
| 20 25 | 
             
             */
         | 
| 21 | 
            -
            export declare const offlineFallback: ( | 
| 26 | 
            +
            export declare const offlineFallback: ({ serwist, pageFallback, imageFallback, fontFallback }: OfflineFallbackOptions) => void;
         | 
| 22 27 | 
             
            //# sourceMappingURL=offlineFallback.d.ts.map
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"offlineFallback.d.ts","sourceRoot":"","sources":["../src/offlineFallback.ts"],"names":[],"mappings":" | 
| 1 | 
            +
            {"version":3,"file":"offlineFallback.d.ts","sourceRoot":"","sources":["../src/offlineFallback.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAA6C,OAAO,EAAE,MAAM,SAAS,CAAC;AAElF,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAKD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,2DAA6E,sBAAsB,KAAG,IAoCjI,CAAC"}
         | 
    
        package/dist/pageCache.d.ts
    CHANGED
    
    | @@ -1,5 +1,10 @@ | |
| 1 | 
            -
            import type { RouteMatchCallback, SerwistPlugin } from " | 
| 1 | 
            +
            import type { RouteMatchCallback, SerwistPlugin } from "serwist";
         | 
| 2 | 
            +
            import { Serwist } from "serwist";
         | 
| 2 3 | 
             
            export interface PageCacheOptions {
         | 
| 4 | 
            +
                /**
         | 
| 5 | 
            +
                 * Your `Serwist` instance.
         | 
| 6 | 
            +
                 */
         | 
| 7 | 
            +
                serwist: Serwist;
         | 
| 3 8 | 
             
                /**
         | 
| 4 9 | 
             
                 * Name for cache. Defaults to pages.
         | 
| 5 10 | 
             
                 */
         | 
| @@ -28,6 +33,5 @@ export interface PageCacheOptions { | |
| 28 33 | 
             
             *
         | 
| 29 34 | 
             
             * @param options
         | 
| 30 35 | 
             
             */
         | 
| 31 | 
            -
            declare  | 
| 32 | 
            -
            export { pageCache };
         | 
| 36 | 
            +
            export declare const pageCache: ({ serwist, cacheName, matchCallback, networkTimeoutSeconds, plugins, warmCache, }: PageCacheOptions) => void;
         | 
| 33 37 | 
             
            //# sourceMappingURL=pageCache.d.ts.map
         | 
    
        package/dist/pageCache.d.ts.map
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"pageCache.d.ts","sourceRoot":"","sources":["../src/pageCache.ts"],"names":[],"mappings":" | 
| 1 | 
            +
            {"version":3,"file":"pageCache.d.ts","sourceRoot":"","sources":["../src/pageCache.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAA6B,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAyC,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzE,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,sFAOnB,gBAAgB,KAAG,IAoBrB,CAAC"}
         | 
| @@ -1,5 +1,10 @@ | |
| 1 | 
            -
            import type { RouteMatchCallback, SerwistPlugin } from " | 
| 1 | 
            +
            import type { RouteMatchCallback, SerwistPlugin } from "serwist";
         | 
| 2 | 
            +
            import { Serwist } from "serwist";
         | 
| 2 3 | 
             
            export interface StaticResourceOptions {
         | 
| 4 | 
            +
                /**
         | 
| 5 | 
            +
                 * Your `Serwist` instance.
         | 
| 6 | 
            +
                 */
         | 
| 7 | 
            +
                serwist: Serwist;
         | 
| 3 8 | 
             
                /**
         | 
| 4 9 | 
             
                 * Name for cache.
         | 
| 5 10 | 
             
                 *
         | 
| @@ -26,6 +31,5 @@ export interface StaticResourceOptions { | |
| 26 31 | 
             
             *
         | 
| 27 32 | 
             
             * @param options
         | 
| 28 33 | 
             
             */
         | 
| 29 | 
            -
            declare  | 
| 30 | 
            -
            export { staticResourceCache };
         | 
| 34 | 
            +
            export declare const staticResourceCache: ({ serwist, cacheName, matchCallback, plugins, warmCache, }: StaticResourceOptions) => void;
         | 
| 31 35 | 
             
            //# sourceMappingURL=staticResourceCache.d.ts.map
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"staticResourceCache.d.ts","sourceRoot":"","sources":["../src/staticResourceCache.ts"],"names":[],"mappings":" | 
| 1 | 
            +
            {"version":3,"file":"staticResourceCache.d.ts","sourceRoot":"","sources":["../src/staticResourceCache.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAA6B,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAA2B,OAAO,EAAwB,MAAM,SAAS,CAAC;AAGjF,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC;;OAEG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,+DAO7B,qBAAqB,KAAG,IAkB1B,CAAC"}
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            import type { Strategy } from " | 
| 1 | 
            +
            import type { Strategy } from "serwist";
         | 
| 2 2 | 
             
            export interface WarmStrategyCacheOptions {
         | 
| 3 3 | 
             
                /**
         | 
| 4 4 | 
             
                 * Paths to warm the strategy's cache with.
         | 
| @@ -12,6 +12,5 @@ export interface WarmStrategyCacheOptions { | |
| 12 12 | 
             
            /**
         | 
| 13 13 | 
             
             * @param options
         | 
| 14 14 | 
             
             */
         | 
| 15 | 
            -
            declare  | 
| 16 | 
            -
            export { warmStrategyCache };
         | 
| 15 | 
            +
            export declare const warmStrategyCache: (options: WarmStrategyCacheOptions) => void;
         | 
| 17 16 | 
             
            //# sourceMappingURL=warmStrategyCache.d.ts.map
         | 
| @@ -1 +1 @@ | |
| 1 | 
            -
            {"version":3,"file":"warmStrategyCache.d.ts","sourceRoot":"","sources":["../src/warmStrategyCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM, | 
| 1 | 
            +
            {"version":3,"file":"warmStrategyCache.d.ts","sourceRoot":"","sources":["../src/warmStrategyCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAKD;;GAEG;AACH,eAAO,MAAM,iBAAiB,YAAa,wBAAwB,KAAG,IAYrE,CAAC"}
         | 
    
        package/package.json
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            {
         | 
| 2 2 | 
             
              "name": "@serwist/recipes",
         | 
| 3 | 
            -
              "version": "9.0. | 
| 3 | 
            +
              "version": "9.0.1",
         | 
| 4 4 | 
             
              "type": "module",
         | 
| 5 5 | 
             
              "description": "A service worker helper library to manage common request and caching patterns",
         | 
| 6 6 | 
             
              "files": [
         | 
| @@ -17,7 +17,7 @@ | |
| 17 17 | 
             
              ],
         | 
| 18 18 | 
             
              "author": "Google's Web DevRel Team, Serwist's Team",
         | 
| 19 19 | 
             
              "license": "MIT",
         | 
| 20 | 
            -
              "repository": "serwist/serwist",
         | 
| 20 | 
            +
              "repository": "https://github.com/serwist/serwist",
         | 
| 21 21 | 
             
              "bugs": "https://github.com/serwist/serwist/issues",
         | 
| 22 22 | 
             
              "homepage": "https://serwist.pages.dev",
         | 
| 23 23 | 
             
              "main": "./dist/index.js",
         | 
| @@ -30,17 +30,12 @@ | |
| 30 30 | 
             
                "./package.json": "./package.json"
         | 
| 31 31 | 
             
              },
         | 
| 32 32 | 
             
              "dependencies": {
         | 
| 33 | 
            -
                " | 
| 34 | 
            -
                "@serwist/core": "9.0.0-preview.9",
         | 
| 35 | 
            -
                "@serwist/expiration": "9.0.0-preview.9",
         | 
| 36 | 
            -
                "@serwist/precaching": "9.0.0-preview.9",
         | 
| 37 | 
            -
                "@serwist/routing": "9.0.0-preview.9",
         | 
| 38 | 
            -
                "@serwist/strategies": "9.0.0-preview.9"
         | 
| 33 | 
            +
                "serwist": "9.0.0"
         | 
| 39 34 | 
             
              },
         | 
| 40 35 | 
             
              "devDependencies": {
         | 
| 41 | 
            -
                "rollup": "4. | 
| 42 | 
            -
                "typescript": "5. | 
| 43 | 
            -
                "@serwist/ | 
| 36 | 
            +
                "rollup": "4.14.3",
         | 
| 37 | 
            +
                "typescript": "5.5.0-dev.20240415",
         | 
| 38 | 
            +
                "@serwist/configs": "9.0.1"
         | 
| 44 39 | 
             
              },
         | 
| 45 40 | 
             
              "peerDependencies": {
         | 
| 46 41 | 
             
                "typescript": ">=5.0.0"
         | 
    
        package/src/googleFontsCache.ts
    CHANGED
    
    | @@ -5,13 +5,13 @@ | |
| 5 5 | 
             
              license that can be found in the LICENSE file or at
         | 
| 6 6 | 
             
              https://opensource.org/licenses/MIT.
         | 
| 7 7 | 
             
            */
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            import { CacheableResponsePlugin } from "@serwist/cacheable-response";
         | 
| 10 | 
            -
            import { ExpirationPlugin } from "@serwist/expiration";
         | 
| 11 | 
            -
            import { registerRoute } from "@serwist/routing";
         | 
| 12 | 
            -
            import { CacheFirst, StaleWhileRevalidate } from "@serwist/strategies";
         | 
| 8 | 
            +
            import { CacheFirst, CacheableResponsePlugin, ExpirationPlugin, Serwist, StaleWhileRevalidate } from "serwist";
         | 
| 13 9 |  | 
| 14 10 | 
             
            export interface GoogleFontCacheOptions {
         | 
| 11 | 
            +
              /**
         | 
| 12 | 
            +
               * Your `Serwist` instance.
         | 
| 13 | 
            +
               */
         | 
| 14 | 
            +
              serwist: Serwist;
         | 
| 15 15 | 
             
              /**
         | 
| 16 16 | 
             
               * Cache prefix for caching stylesheets and webfonts. Defaults to google-fonts.
         | 
| 17 17 | 
             
               */
         | 
| @@ -31,25 +31,25 @@ export interface GoogleFontCacheOptions { | |
| 31 31 | 
             
             *
         | 
| 32 32 | 
             
             * @param options
         | 
| 33 33 | 
             
             */
         | 
| 34 | 
            -
             | 
| 35 | 
            -
               | 
| 36 | 
            -
               | 
| 37 | 
            -
               | 
| 38 | 
            -
               | 
| 39 | 
            -
             | 
| 34 | 
            +
            export const googleFontsCache = ({
         | 
| 35 | 
            +
              serwist,
         | 
| 36 | 
            +
              cachePrefix = "google-fonts",
         | 
| 37 | 
            +
              maxAgeSeconds = 60 * 60 * 24 * 365,
         | 
| 38 | 
            +
              maxEntries = 30,
         | 
| 39 | 
            +
            }: GoogleFontCacheOptions): void => {
         | 
| 40 40 | 
             
              // Cache the Google Fonts stylesheets with a stale-while-revalidate strategy.
         | 
| 41 | 
            -
               | 
| 41 | 
            +
              serwist.registerCapture(
         | 
| 42 42 | 
             
                ({ url }) => url.origin === "https://fonts.googleapis.com",
         | 
| 43 43 | 
             
                new StaleWhileRevalidate({
         | 
| 44 | 
            -
                  cacheName:  | 
| 44 | 
            +
                  cacheName: `${cachePrefix}-stylesheets`,
         | 
| 45 45 | 
             
                }),
         | 
| 46 46 | 
             
              );
         | 
| 47 47 |  | 
| 48 48 | 
             
              // Cache the underlying font files with a cache-first strategy for 1 year.
         | 
| 49 | 
            -
               | 
| 49 | 
            +
              serwist.registerCapture(
         | 
| 50 50 | 
             
                ({ url }) => url.origin === "https://fonts.gstatic.com",
         | 
| 51 51 | 
             
                new CacheFirst({
         | 
| 52 | 
            -
                  cacheName:  | 
| 52 | 
            +
                  cacheName: `${cachePrefix}-webfonts`,
         | 
| 53 53 | 
             
                  plugins: [
         | 
| 54 54 | 
             
                    new CacheableResponsePlugin({
         | 
| 55 55 | 
             
                      statuses: [0, 200],
         | 
| @@ -61,6 +61,4 @@ function googleFontsCache(options: GoogleFontCacheOptions = {}): void { | |
| 61 61 | 
             
                  ],
         | 
| 62 62 | 
             
                }),
         | 
| 63 63 | 
             
              );
         | 
| 64 | 
            -
            }
         | 
| 65 | 
            -
             | 
| 66 | 
            -
            export { googleFontsCache };
         | 
| 64 | 
            +
            };
         | 
    
        package/src/imageCache.ts
    CHANGED
    
    | @@ -6,15 +6,15 @@ | |
| 6 6 | 
             
              https://opensource.org/licenses/MIT.
         | 
| 7 7 | 
             
            */
         | 
| 8 8 |  | 
| 9 | 
            -
            import {  | 
| 10 | 
            -
            import  | 
| 11 | 
            -
            import { ExpirationPlugin } from "@serwist/expiration";
         | 
| 12 | 
            -
            import { registerRoute } from "@serwist/routing";
         | 
| 13 | 
            -
            import { CacheFirst } from "@serwist/strategies";
         | 
| 14 | 
            -
             | 
| 9 | 
            +
            import type { RouteMatchCallback, RouteMatchCallbackOptions, SerwistPlugin } from "serwist";
         | 
| 10 | 
            +
            import { CacheFirst, CacheableResponsePlugin, ExpirationPlugin, Serwist } from "serwist";
         | 
| 15 11 | 
             
            import { warmStrategyCache } from "./warmStrategyCache.js";
         | 
| 16 12 |  | 
| 17 13 | 
             
            export interface ImageCacheOptions {
         | 
| 14 | 
            +
              /**
         | 
| 15 | 
            +
               * Your `Serwist` instance.
         | 
| 16 | 
            +
               */
         | 
| 17 | 
            +
              serwist: Serwist;
         | 
| 18 18 | 
             
              /**
         | 
| 19 19 | 
             
               * Name for cache. Defaults to images.
         | 
| 20 20 | 
             
               */
         | 
| @@ -46,14 +46,15 @@ export interface ImageCacheOptions { | |
| 46 46 | 
             
             *
         | 
| 47 47 | 
             
             * @param options
         | 
| 48 48 | 
             
             */
         | 
| 49 | 
            -
            export const imageCache = ( | 
| 50 | 
            -
               | 
| 51 | 
            -
             | 
| 52 | 
            -
               | 
| 53 | 
            -
               | 
| 54 | 
            -
               | 
| 55 | 
            -
               | 
| 56 | 
            -
               | 
| 49 | 
            +
            export const imageCache = ({
         | 
| 50 | 
            +
              serwist,
         | 
| 51 | 
            +
              cacheName = "images",
         | 
| 52 | 
            +
              matchCallback = ({ request }: RouteMatchCallbackOptions) => request.destination === "image",
         | 
| 53 | 
            +
              maxAgeSeconds = 30 * 24 * 60 * 60,
         | 
| 54 | 
            +
              maxEntries = 60,
         | 
| 55 | 
            +
              plugins = [],
         | 
| 56 | 
            +
              warmCache,
         | 
| 57 | 
            +
            }: ImageCacheOptions): void => {
         | 
| 57 58 | 
             
              plugins.push(
         | 
| 58 59 | 
             
                new CacheableResponsePlugin({
         | 
| 59 60 | 
             
                  statuses: [0, 200],
         | 
| @@ -71,10 +72,10 @@ export const imageCache = (options: ImageCacheOptions = {}): void => { | |
| 71 72 | 
             
                plugins,
         | 
| 72 73 | 
             
              });
         | 
| 73 74 |  | 
| 74 | 
            -
               | 
| 75 | 
            +
              serwist.registerCapture(matchCallback, strategy);
         | 
| 75 76 |  | 
| 76 77 | 
             
              // Warms the cache
         | 
| 77 | 
            -
              if ( | 
| 78 | 
            -
                warmStrategyCache({ urls:  | 
| 78 | 
            +
              if (warmCache) {
         | 
| 79 | 
            +
                warmStrategyCache({ urls: warmCache, strategy });
         | 
| 79 80 | 
             
              }
         | 
| 80 81 | 
             
            };
         | 
    
        package/src/offlineFallback.ts
    CHANGED
    
    | @@ -6,11 +6,13 @@ | |
| 6 6 | 
             
              https://opensource.org/licenses/MIT.
         | 
| 7 7 | 
             
            */
         | 
| 8 8 |  | 
| 9 | 
            -
            import type { RouteHandler, RouteHandlerCallbackOptions } from " | 
| 10 | 
            -
            import { matchPrecache } from "@serwist/precaching";
         | 
| 11 | 
            -
            import { setCatchHandler } from "@serwist/routing";
         | 
| 9 | 
            +
            import type { RouteHandler, RouteHandlerCallbackOptions, Serwist } from "serwist";
         | 
| 12 10 |  | 
| 13 11 | 
             
            export interface OfflineFallbackOptions {
         | 
| 12 | 
            +
              /**
         | 
| 13 | 
            +
               * Your `Serwist` instance.
         | 
| 14 | 
            +
               */
         | 
| 15 | 
            +
              serwist: Serwist;
         | 
| 14 16 | 
             
              /**
         | 
| 15 17 | 
             
               * Precache name to match for page fallbacks. Defaults to offline.html.
         | 
| 16 18 | 
             
               */
         | 
| @@ -34,11 +36,7 @@ declare let self: ServiceWorkerGlobalScope; | |
| 34 36 |  | 
| 35 37 | 
             
             * @param options
         | 
| 36 38 | 
             
             */
         | 
| 37 | 
            -
            export const offlineFallback = ( | 
| 38 | 
            -
              const pageFallback = options.pageFallback || "offline.html";
         | 
| 39 | 
            -
              const imageFallback = options.imageFallback || false;
         | 
| 40 | 
            -
              const fontFallback = options.fontFallback || false;
         | 
| 41 | 
            -
             | 
| 39 | 
            +
            export const offlineFallback = ({ serwist, pageFallback = "offline.html", imageFallback, fontFallback }: OfflineFallbackOptions): void => {
         | 
| 42 40 | 
             
              self.addEventListener("install", (event) => {
         | 
| 43 41 | 
             
                const files = [pageFallback];
         | 
| 44 42 | 
             
                if (imageFallback) {
         | 
| @@ -56,22 +54,22 @@ export const offlineFallback = (options: OfflineFallbackOptions = {}): void => { | |
| 56 54 | 
             
                const cache = await self.caches.open("serwist-offline-fallbacks");
         | 
| 57 55 |  | 
| 58 56 | 
             
                if (dest === "document") {
         | 
| 59 | 
            -
                  const match = (await matchPrecache(pageFallback)) || (await cache.match(pageFallback));
         | 
| 57 | 
            +
                  const match = (await serwist.matchPrecache(pageFallback)) || (await cache.match(pageFallback));
         | 
| 60 58 | 
             
                  return match || Response.error();
         | 
| 61 59 | 
             
                }
         | 
| 62 60 |  | 
| 63 | 
            -
                if (dest === "image" && imageFallback !==  | 
| 64 | 
            -
                  const match = (await matchPrecache(imageFallback)) || (await cache.match(imageFallback));
         | 
| 61 | 
            +
                if (dest === "image" && imageFallback !== undefined) {
         | 
| 62 | 
            +
                  const match = (await serwist.matchPrecache(imageFallback)) || (await cache.match(imageFallback));
         | 
| 65 63 | 
             
                  return match || Response.error();
         | 
| 66 64 | 
             
                }
         | 
| 67 65 |  | 
| 68 | 
            -
                if (dest === "font" && fontFallback !==  | 
| 69 | 
            -
                  const match = (await matchPrecache(fontFallback)) || (await cache.match(fontFallback));
         | 
| 66 | 
            +
                if (dest === "font" && fontFallback !== undefined) {
         | 
| 67 | 
            +
                  const match = (await serwist.matchPrecache(fontFallback)) || (await cache.match(fontFallback));
         | 
| 70 68 | 
             
                  return match || Response.error();
         | 
| 71 69 | 
             
                }
         | 
| 72 70 |  | 
| 73 71 | 
             
                return Response.error();
         | 
| 74 72 | 
             
              };
         | 
| 75 73 |  | 
| 76 | 
            -
              setCatchHandler(handler);
         | 
| 74 | 
            +
              serwist.setCatchHandler(handler);
         | 
| 77 75 | 
             
            };
         | 
    
        package/src/pageCache.ts
    CHANGED
    
    | @@ -6,14 +6,15 @@ | |
| 6 6 | 
             
              https://opensource.org/licenses/MIT.
         | 
| 7 7 | 
             
            */
         | 
| 8 8 |  | 
| 9 | 
            -
            import {  | 
| 10 | 
            -
            import  | 
| 11 | 
            -
            import { registerRoute } from "@serwist/routing";
         | 
| 12 | 
            -
            import { NetworkFirst } from "@serwist/strategies";
         | 
| 13 | 
            -
             | 
| 9 | 
            +
            import type { RouteMatchCallback, RouteMatchCallbackOptions, SerwistPlugin } from "serwist";
         | 
| 10 | 
            +
            import { CacheableResponsePlugin, NetworkFirst, Serwist } from "serwist";
         | 
| 14 11 | 
             
            import { warmStrategyCache } from "./warmStrategyCache.js";
         | 
| 15 12 |  | 
| 16 13 | 
             
            export interface PageCacheOptions {
         | 
| 14 | 
            +
              /**
         | 
| 15 | 
            +
               * Your `Serwist` instance.
         | 
| 16 | 
            +
               */
         | 
| 17 | 
            +
              serwist: Serwist;
         | 
| 17 18 | 
             
              /**
         | 
| 18 19 | 
             
               * Name for cache. Defaults to pages.
         | 
| 19 20 | 
             
               */
         | 
| @@ -43,13 +44,14 @@ export interface PageCacheOptions { | |
| 43 44 | 
             
             *
         | 
| 44 45 | 
             
             * @param options
         | 
| 45 46 | 
             
             */
         | 
| 46 | 
            -
             | 
| 47 | 
            -
               | 
| 48 | 
            -
             | 
| 49 | 
            -
               | 
| 50 | 
            -
               | 
| 51 | 
            -
               | 
| 52 | 
            -
               | 
| 47 | 
            +
            export const pageCache = ({
         | 
| 48 | 
            +
              serwist,
         | 
| 49 | 
            +
              cacheName = "pages",
         | 
| 50 | 
            +
              matchCallback = ({ request }: RouteMatchCallbackOptions) => request.mode === "navigate",
         | 
| 51 | 
            +
              networkTimeoutSeconds = 3,
         | 
| 52 | 
            +
              plugins = [],
         | 
| 53 | 
            +
              warmCache,
         | 
| 54 | 
            +
            }: PageCacheOptions): void => {
         | 
| 53 55 | 
             
              plugins.push(
         | 
| 54 56 | 
             
                new CacheableResponsePlugin({
         | 
| 55 57 | 
             
                  statuses: [0, 200],
         | 
| @@ -63,12 +65,10 @@ function pageCache(options: PageCacheOptions = {}): void { | |
| 63 65 | 
             
              });
         | 
| 64 66 |  | 
| 65 67 | 
             
              // Registers the route
         | 
| 66 | 
            -
               | 
| 68 | 
            +
              serwist.registerCapture(matchCallback, strategy);
         | 
| 67 69 |  | 
| 68 70 | 
             
              // Warms the cache
         | 
| 69 | 
            -
              if ( | 
| 70 | 
            -
                warmStrategyCache({ urls:  | 
| 71 | 
            +
              if (warmCache) {
         | 
| 72 | 
            +
                warmStrategyCache({ urls: warmCache, strategy });
         | 
| 71 73 | 
             
              }
         | 
| 72 | 
            -
            }
         | 
| 73 | 
            -
             | 
| 74 | 
            -
            export { pageCache };
         | 
| 74 | 
            +
            };
         | 
| @@ -6,14 +6,15 @@ | |
| 6 6 | 
             
              https://opensource.org/licenses/MIT.
         | 
| 7 7 | 
             
            */
         | 
| 8 8 |  | 
| 9 | 
            -
            import {  | 
| 10 | 
            -
            import  | 
| 11 | 
            -
            import { registerRoute } from "@serwist/routing";
         | 
| 12 | 
            -
            import { StaleWhileRevalidate } from "@serwist/strategies";
         | 
| 13 | 
            -
             | 
| 9 | 
            +
            import type { RouteMatchCallback, RouteMatchCallbackOptions, SerwistPlugin } from "serwist";
         | 
| 10 | 
            +
            import { CacheableResponsePlugin, Serwist, StaleWhileRevalidate } from "serwist";
         | 
| 14 11 | 
             
            import { warmStrategyCache } from "./warmStrategyCache.js";
         | 
| 15 12 |  | 
| 16 13 | 
             
            export interface StaticResourceOptions {
         | 
| 14 | 
            +
              /**
         | 
| 15 | 
            +
               * Your `Serwist` instance.
         | 
| 16 | 
            +
               */
         | 
| 17 | 
            +
              serwist: Serwist;
         | 
| 17 18 | 
             
              /**
         | 
| 18 19 | 
             
               * Name for cache.
         | 
| 19 20 | 
             
               *
         | 
| @@ -41,13 +42,14 @@ export interface StaticResourceOptions { | |
| 41 42 | 
             
             *
         | 
| 42 43 | 
             
             * @param options
         | 
| 43 44 | 
             
             */
         | 
| 44 | 
            -
             | 
| 45 | 
            -
               | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
               | 
| 50 | 
            -
               | 
| 45 | 
            +
            export const staticResourceCache = ({
         | 
| 46 | 
            +
              serwist,
         | 
| 47 | 
            +
              cacheName = "static-resources",
         | 
| 48 | 
            +
              matchCallback = ({ request }: RouteMatchCallbackOptions) =>
         | 
| 49 | 
            +
                request.destination === "style" || request.destination === "script" || request.destination === "worker",
         | 
| 50 | 
            +
              plugins = [],
         | 
| 51 | 
            +
              warmCache,
         | 
| 52 | 
            +
            }: StaticResourceOptions): void => {
         | 
| 51 53 | 
             
              plugins.push(
         | 
| 52 54 | 
             
                new CacheableResponsePlugin({
         | 
| 53 55 | 
             
                  statuses: [0, 200],
         | 
| @@ -59,12 +61,10 @@ function staticResourceCache(options: StaticResourceOptions = {}): void { | |
| 59 61 | 
             
                plugins,
         | 
| 60 62 | 
             
              });
         | 
| 61 63 |  | 
| 62 | 
            -
               | 
| 64 | 
            +
              serwist.registerCapture(matchCallback, strategy);
         | 
| 63 65 |  | 
| 64 66 | 
             
              // Warms the cache
         | 
| 65 | 
            -
              if ( | 
| 66 | 
            -
                warmStrategyCache({ urls:  | 
| 67 | 
            +
              if (warmCache) {
         | 
| 68 | 
            +
                warmStrategyCache({ urls: warmCache, strategy });
         | 
| 67 69 | 
             
              }
         | 
| 68 | 
            -
            }
         | 
| 69 | 
            -
             | 
| 70 | 
            -
            export { staticResourceCache };
         | 
| 70 | 
            +
            };
         | 
    
        package/src/warmStrategyCache.ts
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            import type { Strategy } from " | 
| 1 | 
            +
            import type { Strategy } from "serwist";
         | 
| 2 2 |  | 
| 3 3 | 
             
            export interface WarmStrategyCacheOptions {
         | 
| 4 4 | 
             
              /**
         | 
| @@ -17,7 +17,7 @@ declare let self: ServiceWorkerGlobalScope; | |
| 17 17 | 
             
            /**
         | 
| 18 18 | 
             
             * @param options
         | 
| 19 19 | 
             
             */
         | 
| 20 | 
            -
             | 
| 20 | 
            +
            export const warmStrategyCache = (options: WarmStrategyCacheOptions): void => {
         | 
| 21 21 | 
             
              self.addEventListener("install", (event) => {
         | 
| 22 22 | 
             
                const done = options.urls.map(
         | 
| 23 23 | 
             
                  (path) =>
         | 
| @@ -29,6 +29,4 @@ function warmStrategyCache(options: WarmStrategyCacheOptions): void { | |
| 29 29 |  | 
| 30 30 | 
             
                event.waitUntil(Promise.all(done));
         | 
| 31 31 | 
             
              });
         | 
| 32 | 
            -
            }
         | 
| 33 | 
            -
             | 
| 34 | 
            -
            export { warmStrategyCache };
         | 
| 32 | 
            +
            };
         |