From 5bea1c96ba80bda4a2ec4c9d449b824fd1a73d50 Mon Sep 17 00:00:00 2001 From: ayoayco Date: Sun, 18 Aug 2024 19:53:44 +0200 Subject: [PATCH] feat: update caching strategy --- package.json | 2 +- pnpm-lock.yaml | 210 ++++++++++++++++++++++++------------------------- src/env.d.ts | 3 +- src/sw.mjs | 52 ++++++------ 4 files changed, 132 insertions(+), 135 deletions(-) diff --git a/package.json b/package.json index 9e0e5eb..f58338b 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@astro-reactive/form": "^0.10.0", "@astro-reactive/validator": "^0.5.0", "@astrojs/sitemap": "^3.1.6", - "@ayco/astro-sw": "^0.7.10", + "@ayco/astro-sw": "^0.8.4", "astro": "^4.14.2", "astro-github-stats": "^0.7.0", "astro-iconify": "^1.2.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5caf54b..e629f45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,22 +10,22 @@ importers: devDependencies: '@astro-reactive/form': specifier: ^0.10.0 - version: 0.10.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4))(rollup@4.20.0)(typescript@5.5.4) + version: 0.10.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4))(rollup@4.21.0)(typescript@5.5.4) '@astro-reactive/validator': specifier: ^0.5.0 - version: 0.5.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4))(rollup@4.20.0)(typescript@5.5.4) + version: 0.5.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4))(rollup@4.21.0)(typescript@5.5.4) '@astrojs/sitemap': specifier: ^3.1.6 version: 3.1.6 '@ayco/astro-sw': - specifier: ^0.7.10 - version: 0.7.10 + specifier: ^0.8.4 + version: 0.8.4 astro: specifier: ^4.14.2 - version: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4) + version: 4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4) astro-github-stats: specifier: ^0.7.0 - version: 0.7.0(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4)) + version: 0.7.0(astro@4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4)) astro-iconify: specifier: ^1.2.0 version: 1.2.0 @@ -75,8 +75,8 @@ packages: resolution: {integrity: sha512-/ca/+D8MIKEC8/A9cSaPUqQNZm+Es/ZinRv0ZAzvu2ios7POQSsVD+VOj7/hypWNsNM3T7RpfgNq7H2TU1KEHA==} engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0} - '@ayco/astro-sw@0.7.10': - resolution: {integrity: sha512-pGXC0mWalsBgb0ZzpRMdqPt4LoUQ6/Tcsm1SrpAqPmMDNraRPxtkvyx9cBm5YQme3AT7SoPk2Q8p+sUKQ4s+WA==} + '@ayco/astro-sw@0.8.4': + resolution: {integrity: sha512-Gv+VoVsCQguFmb0/VHc3J9HxVD2S6KS/HXy+lOwYSOyfx7obKYyRL8pn/qC2HShPVI2V9PSuXHC7vMk0EheT2Q==} engines: {node: '>=18.0.0'} '@babel/code-frame@7.24.7': @@ -611,88 +611,88 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.20.0': - resolution: {integrity: sha512-TSpWzflCc4VGAUJZlPpgAJE1+V60MePDQnBd7PPkpuEmOy8i87aL6tinFGKBFKuEDikYpig72QzdT3QPYIi+oA==} + '@rollup/rollup-android-arm-eabi@4.21.0': + resolution: {integrity: sha512-WTWD8PfoSAJ+qL87lE7votj3syLavxunWhzCnx3XFxFiI/BA/r3X7MUM8dVrH8rb2r4AiO8jJsr3ZjdaftmnfA==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.20.0': - resolution: {integrity: sha512-u00Ro/nok7oGzVuh/FMYfNoGqxU5CPWz1mxV85S2w9LxHR8OoMQBuSk+3BKVIDYgkpeOET5yXkx90OYFc+ytpQ==} + '@rollup/rollup-android-arm64@4.21.0': + resolution: {integrity: sha512-a1sR2zSK1B4eYkiZu17ZUZhmUQcKjk2/j9Me2IDjk1GHW7LB5Z35LEzj9iJch6gtUfsnvZs1ZNyDW2oZSThrkA==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.20.0': - resolution: {integrity: sha512-uFVfvzvsdGtlSLuL0ZlvPJvl6ZmrH4CBwLGEFPe7hUmf7htGAN+aXo43R/V6LATyxlKVC/m6UsLb7jbG+LG39Q==} + '@rollup/rollup-darwin-arm64@4.21.0': + resolution: {integrity: sha512-zOnKWLgDld/svhKO5PD9ozmL6roy5OQ5T4ThvdYZLpiOhEGY+dp2NwUmxK0Ld91LrbjrvtNAE0ERBwjqhZTRAA==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.20.0': - resolution: {integrity: sha512-xbrMDdlev53vNXexEa6l0LffojxhqDTBeL+VUxuuIXys4x6xyvbKq5XqTXBCEUA8ty8iEJblHvFaWRJTk/icAQ==} + '@rollup/rollup-darwin-x64@4.21.0': + resolution: {integrity: sha512-7doS8br0xAkg48SKE2QNtMSFPFUlRdw9+votl27MvT46vo44ATBmdZdGysOevNELmZlfd+NEa0UYOA8f01WSrg==} cpu: [x64] os: [darwin] - '@rollup/rollup-linux-arm-gnueabihf@4.20.0': - resolution: {integrity: sha512-jMYvxZwGmoHFBTbr12Xc6wOdc2xA5tF5F2q6t7Rcfab68TT0n+r7dgawD4qhPEvasDsVpQi+MgDzj2faOLsZjA==} + '@rollup/rollup-linux-arm-gnueabihf@4.21.0': + resolution: {integrity: sha512-pWJsfQjNWNGsoCq53KjMtwdJDmh/6NubwQcz52aEwLEuvx08bzcy6tOUuawAOncPnxz/3siRtd8hiQ32G1y8VA==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.20.0': - resolution: {integrity: sha512-1asSTl4HKuIHIB1GcdFHNNZhxAYEdqML/MW4QmPS4G0ivbEcBr1JKlFLKsIRqjSwOBkdItn3/ZDlyvZ/N6KPlw==} + '@rollup/rollup-linux-arm-musleabihf@4.21.0': + resolution: {integrity: sha512-efRIANsz3UHZrnZXuEvxS9LoCOWMGD1rweciD6uJQIx2myN3a8Im1FafZBzh7zk1RJ6oKcR16dU3UPldaKd83w==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.20.0': - resolution: {integrity: sha512-COBb8Bkx56KldOYJfMf6wKeYJrtJ9vEgBRAOkfw6Ens0tnmzPqvlpjZiLgkhg6cA3DGzCmLmmd319pmHvKWWlQ==} + '@rollup/rollup-linux-arm64-gnu@4.21.0': + resolution: {integrity: sha512-ZrPhydkTVhyeGTW94WJ8pnl1uroqVHM3j3hjdquwAcWnmivjAwOYjTEAuEDeJvGX7xv3Z9GAvrBkEzCgHq9U1w==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.20.0': - resolution: {integrity: sha512-+it+mBSyMslVQa8wSPvBx53fYuZK/oLTu5RJoXogjk6x7Q7sz1GNRsXWjn6SwyJm8E/oMjNVwPhmNdIjwP135Q==} + '@rollup/rollup-linux-arm64-musl@4.21.0': + resolution: {integrity: sha512-cfaupqd+UEFeURmqNP2eEvXqgbSox/LHOyN9/d2pSdV8xTrjdg3NgOFJCtc1vQ/jEke1qD0IejbBfxleBPHnPw==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.20.0': - resolution: {integrity: sha512-yAMvqhPfGKsAxHN8I4+jE0CpLWD8cv4z7CK7BMmhjDuz606Q2tFKkWRY8bHR9JQXYcoLfopo5TTqzxgPUjUMfw==} + '@rollup/rollup-linux-powerpc64le-gnu@4.21.0': + resolution: {integrity: sha512-ZKPan1/RvAhrUylwBXC9t7B2hXdpb/ufeu22pG2psV7RN8roOfGurEghw1ySmX/CmDDHNTDDjY3lo9hRlgtaHg==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.20.0': - resolution: {integrity: sha512-qmuxFpfmi/2SUkAw95TtNq/w/I7Gpjurx609OOOV7U4vhvUhBcftcmXwl3rqAek+ADBwSjIC4IVNLiszoj3dPA==} + '@rollup/rollup-linux-riscv64-gnu@4.21.0': + resolution: {integrity: sha512-H1eRaCwd5E8eS8leiS+o/NqMdljkcb1d6r2h4fKSsCXQilLKArq6WS7XBLDu80Yz+nMqHVFDquwcVrQmGr28rg==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.20.0': - resolution: {integrity: sha512-I0BtGXddHSHjV1mqTNkgUZLnS3WtsqebAXv11D5BZE/gfw5KoyXSAXVqyJximQXNvNzUo4GKlCK/dIwXlz+jlg==} + '@rollup/rollup-linux-s390x-gnu@4.21.0': + resolution: {integrity: sha512-zJ4hA+3b5tu8u7L58CCSI0A9N1vkfwPhWd/puGXwtZlsB5bTkwDNW/+JCU84+3QYmKpLi+XvHdmrlwUwDA6kqw==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.20.0': - resolution: {integrity: sha512-y+eoL2I3iphUg9tN9GB6ku1FA8kOfmF4oUEWhztDJ4KXJy1agk/9+pejOuZkNFhRwHAOxMsBPLbXPd6mJiCwew==} + '@rollup/rollup-linux-x64-gnu@4.21.0': + resolution: {integrity: sha512-e2hrvElFIh6kW/UNBQK/kzqMNY5mO+67YtEh9OA65RM5IJXYTWiXjX6fjIiPaqOkBthYF1EqgiZ6OXKcQsM0hg==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.20.0': - resolution: {integrity: sha512-hM3nhW40kBNYUkZb/r9k2FKK+/MnKglX7UYd4ZUy5DJs8/sMsIbqWK2piZtVGE3kcXVNj3B2IrUYROJMMCikNg==} + '@rollup/rollup-linux-x64-musl@4.21.0': + resolution: {integrity: sha512-1vvmgDdUSebVGXWX2lIcgRebqfQSff0hMEkLJyakQ9JQUbLDkEaMsPTLOmyccyC6IJ/l3FZuJbmrBw/u0A0uCQ==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.20.0': - resolution: {integrity: sha512-psegMvP+Ik/Bg7QRJbv8w8PAytPA7Uo8fpFjXyCRHWm6Nt42L+JtoqH8eDQ5hRP7/XW2UiIriy1Z46jf0Oa1kA==} + '@rollup/rollup-win32-arm64-msvc@4.21.0': + resolution: {integrity: sha512-s5oFkZ/hFcrlAyBTONFY1TWndfyre1wOMwU+6KCpm/iatybvrRgmZVM+vCFwxmC5ZhdlgfE0N4XorsDpi7/4XQ==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.20.0': - resolution: {integrity: sha512-GabekH3w4lgAJpVxkk7hUzUf2hICSQO0a/BLFA11/RMxQT92MabKAqyubzDZmMOC/hcJNlc+rrypzNzYl4Dx7A==} + '@rollup/rollup-win32-ia32-msvc@4.21.0': + resolution: {integrity: sha512-G9+TEqRnAA6nbpqyUqgTiopmnfgnMkR3kMukFBDsiyy23LZvUCpiUwjTRx6ezYCjJODXrh52rBR9oXvm+Fp5wg==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.20.0': - resolution: {integrity: sha512-aJ1EJSuTdGnM6qbVC4B5DSmozPTqIag9fSzXRNNo+humQLG89XpPgdt16Ia56ORD7s+H8Pmyx44uczDQ0yDzpg==} + '@rollup/rollup-win32-x64-msvc@4.21.0': + resolution: {integrity: sha512-2jsCDZwtQvRhejHLfZ1JY6w6kEuEtfF9nzYsZxzSlNVKDX+DpsDJ+Rbjkm74nvg2rdx0gwBS+IMdvwJuq3S9pQ==} cpu: [x64] os: [win32] - '@shikijs/core@1.13.0': - resolution: {integrity: sha512-Mj5NVfbAXcD1GnwOTSPl8hBn/T8UDpfFQTptp+p41n/CbUcJtOq98WaRD7Lz3hCglYotUTHUWtzu3JhK6XlkAA==} + '@shikijs/core@1.14.1': + resolution: {integrity: sha512-KyHIIpKNaT20FtFPFjCQB5WVSTpLR/n+jQXhWHWVUMm9MaOaG9BGOG0MSyt7yA4+Lm+4c9rTc03tt3nYzeYSfw==} '@trysound/sax@0.2.0': resolution: {integrity: sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA==} @@ -1034,8 +1034,8 @@ packages: eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - electron-to-chromium@1.5.10: - resolution: {integrity: sha512-C3RDERDjrNW262GCRvpoer3a0Ksd66CtgDLxMHhzShQ8fhL4kwnpVXsJPAKg9xJjIROXUbLBrvtOzVAjALMIWA==} + electron-to-chromium@1.5.11: + resolution: {integrity: sha512-R1CccCDYqndR25CaXFd6hp/u9RaaMcftMkphmvuepXr5b1vfLkRml6aWVeBhXJ7rbevHkKEMJtz8XqPf7ffmew==} emoji-regex@10.3.0: resolution: {integrity: sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==} @@ -1812,8 +1812,8 @@ packages: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - rollup@4.20.0: - resolution: {integrity: sha512-6rbWBChcnSGzIlXeIdNIZTopKYad8ZG8ajhl78lGRLsI2rX8IkaotQhVas2Ma+GPxJav19wrSzvRvuiv0YKzWw==} + rollup@4.21.0: + resolution: {integrity: sha512-vo+S/lfA2lMS7rZ2Qoubi6I5hwZwzXeUIctILZLbHI+laNtvhhOIon2S1JksA5UEDQ7l3vberd0fxK44lTYjbQ==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -1851,8 +1851,8 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - shiki@1.13.0: - resolution: {integrity: sha512-e0dWfnONbEv6xl7FJy3XIhsVHQ/65XHDZl92+6H9+4xWjfdo7pmkqG7Kg47KWtDiEtzM5Z+oEfb4vtRvoZ/X9w==} + shiki@1.14.1: + resolution: {integrity: sha512-FujAN40NEejeXdzPt+3sZ3F2dx1U24BY2XTY01+MG8mbxCiA2XukXdcbyMyLAHJ/1AUUnQd1tZlvIjefWWEJeA==} short-unique-id@4.4.4: resolution: {integrity: sha512-oLF1NCmtbiTWl2SqdXZQbo5KM1b7axdp0RgQLq8qCBBLoq+o3A5wmLrNM6bZIh54/a8BJ3l69kTXuxwZ+XCYuw==} @@ -2169,9 +2169,9 @@ snapshots: '@antfu/utils@0.7.10': {} - '@astro-reactive/common@0.3.0(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4)': + '@astro-reactive/common@0.3.0(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4)': dependencies: - astro: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4) + astro: 4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4) transitivePeerDependencies: - '@types/node' - less @@ -2185,11 +2185,11 @@ snapshots: - terser - typescript - '@astro-reactive/form@0.10.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4))(rollup@4.20.0)(typescript@5.5.4)': + '@astro-reactive/form@0.10.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4))(rollup@4.21.0)(typescript@5.5.4)': dependencies: - '@astro-reactive/common': 0.3.0(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4) - '@astro-reactive/validator': 0.5.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4))(rollup@4.20.0)(typescript@5.5.4) - astro: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4) + '@astro-reactive/common': 0.3.0(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4) + '@astro-reactive/validator': 0.5.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4))(rollup@4.21.0)(typescript@5.5.4) + astro: 4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4) short-unique-id: 4.4.4 transitivePeerDependencies: - '@types/node' @@ -2204,10 +2204,10 @@ snapshots: - terser - typescript - '@astro-reactive/validator@0.5.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4))(rollup@4.20.0)(typescript@5.5.4)': + '@astro-reactive/validator@0.5.0(@types/node@22.4.0)(astro@4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4))(rollup@4.21.0)(typescript@5.5.4)': dependencies: - '@astro-reactive/common': 0.3.0(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4) - astro: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4) + '@astro-reactive/common': 0.3.0(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4) + astro: 4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4) transitivePeerDependencies: - '@types/node' - less @@ -2239,7 +2239,7 @@ snapshots: remark-parse: 11.0.0 remark-rehype: 11.1.0 remark-smartypants: 3.0.2 - shiki: 1.13.0 + shiki: 1.14.1 unified: 11.0.5 unist-util-remove-position: 5.0.0 unist-util-visit: 5.0.0 @@ -2270,7 +2270,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@ayco/astro-sw@0.7.10': + '@ayco/astro-sw@0.8.4': dependencies: esbuild: 0.23.1 pathe: 1.1.2 @@ -2692,63 +2692,63 @@ snapshots: '@oslojs/encoding@0.4.1': {} - '@rollup/pluginutils@5.1.0(rollup@4.20.0)': + '@rollup/pluginutils@5.1.0(rollup@4.21.0)': dependencies: '@types/estree': 1.0.5 estree-walker: 2.0.2 picomatch: 2.3.1 optionalDependencies: - rollup: 4.20.0 + rollup: 4.21.0 - '@rollup/rollup-android-arm-eabi@4.20.0': + '@rollup/rollup-android-arm-eabi@4.21.0': optional: true - '@rollup/rollup-android-arm64@4.20.0': + '@rollup/rollup-android-arm64@4.21.0': optional: true - '@rollup/rollup-darwin-arm64@4.20.0': + '@rollup/rollup-darwin-arm64@4.21.0': optional: true - '@rollup/rollup-darwin-x64@4.20.0': + '@rollup/rollup-darwin-x64@4.21.0': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.20.0': + '@rollup/rollup-linux-arm-gnueabihf@4.21.0': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.20.0': + '@rollup/rollup-linux-arm-musleabihf@4.21.0': optional: true - '@rollup/rollup-linux-arm64-gnu@4.20.0': + '@rollup/rollup-linux-arm64-gnu@4.21.0': optional: true - '@rollup/rollup-linux-arm64-musl@4.20.0': + '@rollup/rollup-linux-arm64-musl@4.21.0': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.20.0': + '@rollup/rollup-linux-powerpc64le-gnu@4.21.0': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.20.0': + '@rollup/rollup-linux-riscv64-gnu@4.21.0': optional: true - '@rollup/rollup-linux-s390x-gnu@4.20.0': + '@rollup/rollup-linux-s390x-gnu@4.21.0': optional: true - '@rollup/rollup-linux-x64-gnu@4.20.0': + '@rollup/rollup-linux-x64-gnu@4.21.0': optional: true - '@rollup/rollup-linux-x64-musl@4.20.0': + '@rollup/rollup-linux-x64-musl@4.21.0': optional: true - '@rollup/rollup-win32-arm64-msvc@4.20.0': + '@rollup/rollup-win32-arm64-msvc@4.21.0': optional: true - '@rollup/rollup-win32-ia32-msvc@4.20.0': + '@rollup/rollup-win32-ia32-msvc@4.21.0': optional: true - '@rollup/rollup-win32-x64-msvc@4.20.0': + '@rollup/rollup-win32-x64-msvc@4.21.0': optional: true - '@shikijs/core@1.13.0': + '@shikijs/core@1.14.1': dependencies: '@types/hast': 3.0.4 @@ -2851,9 +2851,9 @@ snapshots: array-iterate@2.0.1: {} - astro-github-stats@0.7.0(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4)): + astro-github-stats@0.7.0(astro@4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4)): dependencies: - astro: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4) + astro: 4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4) astro-iconify@1.2.0: dependencies: @@ -2865,7 +2865,7 @@ snapshots: - debug - supports-color - astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(typescript@5.5.4): + astro@4.14.2(@types/node@22.4.0)(rollup@4.21.0)(typescript@5.5.4): dependencies: '@astrojs/compiler': 2.10.3 '@astrojs/internal-helpers': 0.4.1 @@ -2878,7 +2878,7 @@ snapshots: '@babel/traverse': 7.25.3 '@babel/types': 7.25.2 '@oslojs/encoding': 0.4.1 - '@rollup/pluginutils': 5.1.0(rollup@4.20.0) + '@rollup/pluginutils': 5.1.0(rollup@4.21.0) '@types/babel__core': 7.20.5 '@types/cookie': 0.6.0 acorn: 8.12.1 @@ -2920,7 +2920,7 @@ snapshots: prompts: 2.4.2 rehype: 13.0.1 semver: 7.6.3 - shiki: 1.13.0 + shiki: 1.14.1 string-width: 7.2.0 strip-ansi: 7.1.0 tsconfck: 3.1.1(typescript@5.5.4) @@ -2985,7 +2985,7 @@ snapshots: browserslist@4.23.3: dependencies: caniuse-lite: 1.0.30001651 - electron-to-chromium: 1.5.10 + electron-to-chromium: 1.5.11 node-releases: 2.0.18 update-browserslist-db: 1.1.0(browserslist@4.23.3) @@ -3175,7 +3175,7 @@ snapshots: eastasianwidth@0.2.0: {} - electron-to-chromium@1.5.10: {} + electron-to-chromium@1.5.11: {} emoji-regex@10.3.0: {} @@ -4235,26 +4235,26 @@ snapshots: reusify@1.0.4: {} - rollup@4.20.0: + rollup@4.21.0: dependencies: '@types/estree': 1.0.5 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.20.0 - '@rollup/rollup-android-arm64': 4.20.0 - '@rollup/rollup-darwin-arm64': 4.20.0 - '@rollup/rollup-darwin-x64': 4.20.0 - '@rollup/rollup-linux-arm-gnueabihf': 4.20.0 - '@rollup/rollup-linux-arm-musleabihf': 4.20.0 - '@rollup/rollup-linux-arm64-gnu': 4.20.0 - '@rollup/rollup-linux-arm64-musl': 4.20.0 - '@rollup/rollup-linux-powerpc64le-gnu': 4.20.0 - '@rollup/rollup-linux-riscv64-gnu': 4.20.0 - '@rollup/rollup-linux-s390x-gnu': 4.20.0 - '@rollup/rollup-linux-x64-gnu': 4.20.0 - '@rollup/rollup-linux-x64-musl': 4.20.0 - '@rollup/rollup-win32-arm64-msvc': 4.20.0 - '@rollup/rollup-win32-ia32-msvc': 4.20.0 - '@rollup/rollup-win32-x64-msvc': 4.20.0 + '@rollup/rollup-android-arm-eabi': 4.21.0 + '@rollup/rollup-android-arm64': 4.21.0 + '@rollup/rollup-darwin-arm64': 4.21.0 + '@rollup/rollup-darwin-x64': 4.21.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.21.0 + '@rollup/rollup-linux-arm-musleabihf': 4.21.0 + '@rollup/rollup-linux-arm64-gnu': 4.21.0 + '@rollup/rollup-linux-arm64-musl': 4.21.0 + '@rollup/rollup-linux-powerpc64le-gnu': 4.21.0 + '@rollup/rollup-linux-riscv64-gnu': 4.21.0 + '@rollup/rollup-linux-s390x-gnu': 4.21.0 + '@rollup/rollup-linux-x64-gnu': 4.21.0 + '@rollup/rollup-linux-x64-musl': 4.21.0 + '@rollup/rollup-win32-arm64-msvc': 4.21.0 + '@rollup/rollup-win32-ia32-msvc': 4.21.0 + '@rollup/rollup-win32-x64-msvc': 4.21.0 fsevents: 2.3.3 run-parallel@1.2.0: @@ -4307,9 +4307,9 @@ snapshots: shebang-regex@3.0.0: {} - shiki@1.13.0: + shiki@1.14.1: dependencies: - '@shikijs/core': 1.13.0 + '@shikijs/core': 1.14.1 '@types/hast': 3.0.4 short-unique-id@4.4.4: {} @@ -4509,7 +4509,7 @@ snapshots: dependencies: esbuild: 0.21.5 postcss: 8.4.41 - rollup: 4.20.0 + rollup: 4.21.0 optionalDependencies: '@types/node': 22.4.0 fsevents: 2.3.3 diff --git a/src/env.d.ts b/src/env.d.ts index acef35f..9bc5cb4 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -1,2 +1 @@ -/// -/// +/// \ No newline at end of file diff --git a/src/sw.mjs b/src/sw.mjs index 7632d5c..b0dd206 100644 --- a/src/sw.mjs +++ b/src/sw.mjs @@ -5,15 +5,23 @@ */ const cacheName = `${__prefix ?? 'app'}-v${__version ?? '000'}` +const cleanOldCaches = async () => { + const allowCacheNames = ['cozy-reader', cacheName]; + const allCaches = await caches.keys(); + allCaches.forEach(key => { + if(!allowCacheNames.includes(key)) { + caches.delete(key); + } + }); +} + const addResourcesToCache = async (resources) => { const cache = await caches.open(cacheName); - console.log('[personal-sw]: adding resources to cache...', resources) - await cache.addAll(new Set([...resources])); + await cache.addAll(resources); }; const putInCache = async (request, response) => { const cache = await caches.open(cacheName); - console.log('[personal-sw]: adding one response to cache...', request.url) // if exists, replace const keys = await cache.keys(); @@ -26,7 +34,7 @@ const putInCache = async (request, response) => { const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl }) => { - + const cache = await caches.open(cacheName); // Try get the resource from the cache @@ -34,22 +42,17 @@ const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl try { // get network response for revalidation of stale assets const responseFromNetwork = await fetch(request.clone()); - if (responseFromNetwork) { - console.info('[personal-sw]: fetched updated assets', responseFromNetwork.url); + if(responseFromNetwork) { putInCache(request, responseFromNetwork.clone()); } - if (responseFromCache) { - console.info('[personal-sw]: using cached response', responseFromCache.url); + if(responseFromCache) { return responseFromCache; - } else{ - console.info('[personal-sw]: using network response', responseFromNetwork.url); + } else { return responseFromNetwork; } - } catch(error) { - console.info('[personal-sw]: failed to fetch updated assets', request.url); - if (responseFromCache) { - console.info('[personal-sw]: using cached response', responseFromCache.url); + } catch (error) { + if(responseFromCache) { return responseFromCache; } } @@ -61,28 +64,25 @@ const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl // To avoid those errors, remove or comment out this block of preloadResponse // code along with enableNavigationPreload() and the "activate" listener. const preloadResponse = await preloadResponsePromise; - if (preloadResponse) { + if(preloadResponse) { putInCache(request, preloadResponse.clone()); - console.info('[personal-sw]: using preload response', preloadResponse.url); return preloadResponse; } try { // Try to get the resource from the network for 5 seconds - const responseFromNetwork = await fetch(request.clone(), {signal: AbortSignal.timeout(5000)}); + const responseFromNetwork = await fetch(request.clone()); // response may be used only once // we need to save clone to put one copy in cache // and serve second one putInCache(request, responseFromNetwork.clone()); - console.info('[personal-sw]: using network response', responseFromNetwork.url); return responseFromNetwork; } catch (error) { // Try the fallback const fallbackResponse = await cache.match(fallbackUrl); - if (fallbackResponse) { - console.info('[personal-sw]: using fallback cached response', fallbackResponse.url); + if(fallbackResponse) { return fallbackResponse; } @@ -97,27 +97,25 @@ const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl }; const enableNavigationPreload = async () => { - if (self.registration.navigationPreload) { + if(self.registration.navigationPreload) { // Enable navigation preloads! await self.registration.navigationPreload.enable(); } }; -self.addEventListener('activate', (event) => { - console.log('[personal-sw]: activating...', event) +self.addEventListener('activate', (event) => { + cleanOldCaches(); event.waitUntil(enableNavigationPreload()); }); -self.addEventListener('install', (event) => { - console.log('[personal-sw]: installing...', event) +self.addEventListener('install', (event) => { event.waitUntil( addResourcesToCache(__assets ?? []) ); self.skipWaiting(); // activate updated SW }); -self.addEventListener('event', (event) => { - // ... else, use network first +self.addEventListener('fetch', (event) => { event.respondWith( cacheAndRevalidate({ request: event.request,