Skip to content

Commit

Permalink
fix(sw): fixed broken PWAScripts component
Browse files Browse the repository at this point in the history
  • Loading branch information
ShafSpecs committed Mar 2, 2025
1 parent 38c1b09 commit ece0d1e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/sw/src/components/PWAScripts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ export const PWAScripts = (props: ScriptProps) => {
const registerSwHtml = `
async function register() {
const reg = await navigator.serviceWorker.register('/${props.workerName ?? 'entry.worker'}.js', {
scope: ${JSON.stringify(props.scope) ?? '/'},
type: ${JSON.stringify(props.serviceWorkerType) ?? 'classic'},
scope: '${JSON.stringify(props.scope) ?? '/'}',
type: '${JSON.stringify(props.serviceWorkerType) ?? 'classic'}',
updateViaCache: 'none',
});
window.$ServiceWorkerHMRHandler$ = async () => {
await reg.update();
}
}
if ('serviceWorker' in navigator) {,
if (document.readyState === 'complete' || document.readyState === 'interactive') {,
register();,
} else {,
window.addEventListener('load', register);,
},
if ('serviceWorker' in navigator) {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
register();
} else {
window.addEventListener('load', register);
}
}
`
.trim()
.split('\n')
.map(line => line.trim)
.map(line => line.trim())
.join('\n');

return (
Expand Down

0 comments on commit ece0d1e

Please sign in to comment.