Skip to content

Commit ea1a58b

Browse files
authored
fix(client): multiple clients with prompt for update (#394)
1 parent d8d2d36 commit ea1a58b

File tree

17 files changed

+56
-63
lines changed

17 files changed

+56
-63
lines changed

client.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ declare module 'virtual:pwa-register' {
2020
onRegisterError?: (error: any) => void
2121
}
2222

23+
/**
24+
* Registers the service worker returning a callback to reload the current page when an update is found.
25+
*
26+
* @param options the options to register the service worker.
27+
* @return (reloadPage?: boolean) => Promise<void> From version 0.13.2+ `reloadPage` param is not used anymore.
28+
*/
2329
export function registerSW(options?: RegisterSWOptions): (reloadPage?: boolean) => Promise<void>
2430
}
2531

@@ -52,6 +58,11 @@ declare module 'virtual:pwa-register/vue' {
5258
export function useRegisterSW(options?: RegisterSWOptions): {
5359
needRefresh: Ref<boolean>
5460
offlineReady: Ref<boolean>
61+
/**
62+
* Reloads the current window to allow the service worker take the control.
63+
*
64+
* @param reloadPage From version 0.13.2+ this param is not used anymore.
65+
*/
5566
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
5667
}
5768
}
@@ -85,6 +96,11 @@ declare module 'virtual:pwa-register/svelte' {
8596
export function useRegisterSW(options?: RegisterSWOptions): {
8697
needRefresh: Writable<boolean>
8798
offlineReady: Writable<boolean>
99+
/**
100+
* Reloads the current window to allow the service worker take the control.
101+
*
102+
* @param reloadPage From version 0.13.2+ this param is not used anymore.
103+
*/
88104
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
89105
}
90106
}
@@ -118,6 +134,11 @@ declare module 'virtual:pwa-register/react' {
118134
export function useRegisterSW(options?: RegisterSWOptions): {
119135
needRefresh: [boolean, Dispatch<SetStateAction<boolean>>]
120136
offlineReady: [boolean, Dispatch<SetStateAction<boolean>>]
137+
/**
138+
* Reloads the current window to allow the service worker take the control.
139+
*
140+
* @param reloadPage From version 0.13.2+ this param is not used anymore.
141+
*/
121142
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
122143
}
123144
}
@@ -151,6 +172,11 @@ declare module 'virtual:pwa-register/solid' {
151172
export function useRegisterSW(options?: RegisterSWOptions): {
152173
needRefresh: [Accessor<boolean>, Setter<boolean>]
153174
offlineReady: [Accessor<boolean>, Setter<boolean>]
175+
/**
176+
* Reloads the current window to allow the service worker take the control.
177+
*
178+
* @param reloadPage From version 0.13.2+ this param is not used anymore.
179+
*/
154180
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
155181
}
156182
}
@@ -184,6 +210,11 @@ declare module 'virtual:pwa-register/preact' {
184210
export function useRegisterSW(options?: RegisterSWOptions): {
185211
needRefresh: [boolean, StateUpdater<boolean>]
186212
offlineReady: [boolean, StateUpdater<boolean>]
213+
/**
214+
* Reloads the current window to allow the service worker take the control.
215+
*
216+
* @param reloadPage From version 0.13.2+ this param is not used anymore.
217+
*/
187218
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
188219
}
189220
}

docs/.vitepress/components.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ declare module '@vue/runtime-core' {
1313
ExamplesInjectManifest: typeof import('./theme/components/ExamplesInjectManifest.md')['default']
1414
GenerateSWCleanupOutdatedCaches: typeof import('./theme/components/GenerateSWCleanupOutdatedCaches.md')['default']
1515
GenerateSWSourceMap: typeof import('./theme/components/GenerateSWSourceMap.md')['default']
16-
HeuristicWorkboxWindow: typeof import('./theme/components/HeuristicWorkboxWindow.md')['default']
1716
HomePage: typeof import('./theme/components/HomePage.vue')['default']
1817
InjectManifestCleanupOutdatedCaches: typeof import('./theme/components/InjectManifestCleanupOutdatedCaches.md')['default']
1918
InjectManifestSourceMap: typeof import('./theme/components/InjectManifestSourceMap.md')['default']

docs/.vitepress/theme/components/HeuristicWorkboxWindow.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/examples/preact.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ Done. Now run:
3131

3232
To test `new content available`, you should rerun the corresponding script, and then refresh the page.
3333

34-
If you are running an example with `Periodic SW updates`, you will need to wait 1 minute:
35-
<HeuristicWorkboxWindow />
36-
3734
## Executing the examples
3835

3936
<RunExamples />

docs/examples/react.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ Done. Now run:
3131

3232
To test `new content available`, you should rerun the corresponding script, and then refresh the page.
3333

34-
If you are running an example with `Periodic SW updates`, you will need to wait 1 minute:
35-
<HeuristicWorkboxWindow />
36-
3734
## Executing the examples
3835

3936
<RunExamples />

docs/examples/solidjs.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ npx degit solidjs/templates/ts-router solid-router
2020

2121
To test `new content available`, you should rerun the corresponding script, and then refresh the page.
2222

23-
If you are running an example with `Periodic SW updates`, you will need to wait 1 minute:
24-
<HeuristicWorkboxWindow />
25-
2623
## Executing the examples
2724

2825
<RunExamples />

docs/examples/svelte.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ Done. Now run:
3030

3131
To test `new content available`, you should rerun the corresponding script, and then refresh the page.
3232

33-
If you are running an example with `Periodic SW updates`, you will need to wait 1 minute:
34-
<HeuristicWorkboxWindow />
35-
3633
## Executing the examples
3734

3835
<RunExamples />

docs/examples/sveltekit.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ Next steps:
4747
4848
To test `new content available`, you should rerun the corresponding script, and then refresh the page.
4949
50-
If you are running an example with `Periodic SW updates`, you will need to wait 1 minute:
51-
52-
<HeuristicWorkboxWindow />
53-
5450
## Executing the examples
5551
5652
<RunExamples />

docs/examples/vue.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ Done. Now run:
3131

3232
To test `new content available`, you should rerun the corresponding script, and then refresh the page.
3333

34-
If you are running an example with `Periodic SW updates`, you will need to wait 1 minute:
35-
<HeuristicWorkboxWindow />
36-
3734
## Executing the examples
3835

3936
<RunExamples />

docs/frameworks/preact.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,3 @@ const updateServiceWorker = useRegisterSW({
157157
```
158158

159159
The interval must be in milliseconds, in the example above it is configured to check the service worker every hour.
160-
161-
<HeuristicWorkboxWindow />

0 commit comments

Comments
 (0)