feat: new experimental Strategies export

This commit is contained in:
Ayo Ayco 2024-08-19 13:53:19 +02:00
parent 2e94226b1c
commit 0c8d5edd77
4 changed files with 18 additions and 1 deletions

View file

@ -3,6 +3,7 @@
import { defineConfig } from "astro/config";
import node from "@astrojs/node";
import serviceWorker from "./packages/index.js";
import { Strategies } from "./packages/strategies/index.js";
export default defineConfig({
output: "hybrid",
@ -32,6 +33,9 @@ export default defineConfig({
const sw = await navigator.serviceWorker.getRegistration();
console.log('>>> registrered', sw)
}
},
experimental: {
strategy: Strategies.CacheRevalidatePreloadFallback,
}
})
]

View file

@ -33,6 +33,14 @@ const ASTROSW = '@ayco/astro-sw';
* unsupported?: () => void,
* afterRegistration?: () => void,
* }
* experimental?: {
* strategy?: {
* fetchFn: () => void,
* installFn: () => void,
* activateFn: () => void,
* waitFn: () => void,
* }
* }
* }} options
* @returns {AstroIntegration}
*/

View file

@ -142,7 +142,7 @@ const fetchFn = (event) => {
const waitFn = (event) => {}
export default {
export const CacheRevalidatePreloadFallback = {
fetchFn,
installFn,
activateFn,

View file

@ -0,0 +1,5 @@
import { CacheRevalidatePreloadFallback } from "./CacheRevalidatePreloadFallback.js";
export const Strategies = {
CacheRevalidatePreloadFallback
}