File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff line change 11import { registerSW } from 'virtual:pwa-register'
2+ import { isDev } from '@components/scripts/utils/environmentClient'
23
3- const registerServiceWorker = ( ) => {
4+ export const registerServiceWorker = ( ) => {
45 const hasServiceWorker = 'serviceWorker' in navigator
56 console . info ( '[pwa] register-sw start' , { hasServiceWorker } )
67
78 if ( ! hasServiceWorker ) {
89 return
910 }
1011
12+ if ( isDev ( ) ) {
13+ void navigator . serviceWorker . getRegistrations ( ) . then ( ( registrations ) => {
14+ registrations . forEach ( ( registration ) => {
15+ console . info ( '[pwa] unregistering dev service worker' , { scope : registration . scope } )
16+ void registration . unregister ( )
17+ } )
18+ } )
19+ return
20+ }
21+
1122 const updateSW = registerSW ( {
1223 immediate : false ,
1324 onNeedRefresh ( ) {
@@ -32,7 +43,4 @@ const registerServiceWorker = () => {
3243 console . info ( '[pwa] register-sw hooked update handler' )
3344
3445 window . __pwaUpdateSW = updateSW
35-
3646}
37-
38- registerServiceWorker ( )
Original file line number Diff line number Diff line change 1+ <script >
2+ import { registerServiceWorker } from '/src/components/Pwa/ServiceWorker/client'
3+ registerServiceWorker()
4+ </script >
File renamed without changes.
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ import Footer from '@components/Footer/index.astro'
66import HeadContent from ' @components/Head/index.astro'
77import Header from ' @components/Header/index.astro'
88import Content from ' @components/Layout/Content/index.astro'
9- import PwaTitleBar from ' @components/PwaTitleBar /index.astro'
10- import RegisterSW from ' @components/Pwa/RegisterSW .astro'
9+ import PwaTitleBar from ' @components/Pwa/TitleBar /index.astro'
10+ import RegisterServiceWorker from ' @components/Pwa/ServiceWorker/index .astro'
1111import Skip from ' @components/Layout/Skip/index.astro'
1212import ThemePicker from ' @components/ThemePicker/index.astro'
1313import { ClientRouter } from ' astro:transitions'
@@ -97,7 +97,7 @@ const {
9797 <Footer />
9898 </Container >
9999 { /* Register the service worker via @vite-pwa/astro virtual module */ }
100- <RegisterSW />
100+ <RegisterServiceWorker />
101101 </body >
102102 </>
103103</html >
You can’t perform that action at this time.
0 commit comments