@tracktor/shared-module 2.17.1 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -3
- package/dist/components/Utils/UpdateNotifier.d.ts +45 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +380 -346
- package/dist/main.umd.cjs +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [2.
|
|
3
|
+
## [2.18.0] - 2025-09-30
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
-
|
|
5
|
+
### ✨ Features
|
|
6
|
+
- introduce `AppUpdateHandler` component to monitor Service Worker updates and prompt users when a new version of the app is available
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface UpdateNotifierProps {
|
|
3
|
+
/**
|
|
4
|
+
* If true, clears all CacheStorage entries before reloading.
|
|
5
|
+
* Default false to avoid wiping host-origin caches unexpectedly.
|
|
6
|
+
*/
|
|
7
|
+
clearCachesOnReload?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Optional custom component to display when an update is available.
|
|
10
|
+
* It receives an `onReload` callback that should be called to reload the app.
|
|
11
|
+
*/
|
|
12
|
+
renderDialog?: (handleReloadApp: () => void) => ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* UpdateNotifier monitors Service Worker updates and informs the user
|
|
16
|
+
* when a new version of the app is available.
|
|
17
|
+
*
|
|
18
|
+
* Behavior:
|
|
19
|
+
* - Detects when a new Service Worker has been installed and is waiting to activate.
|
|
20
|
+
* - If a custom `renderDialog` component is provided, it will be rendered when an update is available,
|
|
21
|
+
* and will receive an `onReload` callback to trigger the reload flow.
|
|
22
|
+
* - If no `renderDialog` is provided, a default `window.confirm` prompt is shown,
|
|
23
|
+
* and the app reloads automatically after user confirmation.
|
|
24
|
+
* - If `clearCachesOnReload` is true, all entries in CacheStorage will be cleared before reloading
|
|
25
|
+
* (use with caution, as this removes *all* caches for the current origin).
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* Place <UpdateNotifier /> once at the root of your app (e.g., in App.tsx).
|
|
29
|
+
*
|
|
30
|
+
* Example with a custom banner:
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <UpdateNotifier
|
|
33
|
+
* renderDialog={(handleReloadApp) => (
|
|
34
|
+
* <div style={{ position: "fixed", bottom: 0, width: "100%", background: "orange", padding: "1rem" }}>
|
|
35
|
+
* <span>A new version is available.</span>
|
|
36
|
+
* <button onClick={onReload} style={{ marginLeft: "1rem" }}>
|
|
37
|
+
* Reload now
|
|
38
|
+
* </button>
|
|
39
|
+
* </div>
|
|
40
|
+
* )}
|
|
41
|
+
* />
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const UpdateNotifier: ({ renderDialog, clearCachesOnReload }: UpdateNotifierProps) => ReactNode;
|
|
45
|
+
export default UpdateNotifier;
|
package/dist/main.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export { default as InitializeDaysJSConfig } from './components/Utils/Initialize
|
|
|
15
15
|
export * from './components/Utils/InitializeDaysJSConfig';
|
|
16
16
|
export { default as PreloadErrorHandler } from './components/Utils/PreloadErrorHandler';
|
|
17
17
|
export * from './components/Utils/PreloadErrorHandler';
|
|
18
|
+
export { default as UpdateNotifier } from './components/Utils/UpdateNotifier';
|
|
19
|
+
export * from './components/Utils/UpdateNotifier';
|
|
18
20
|
export { default as InjectDependenciesProvider } from './context/InjectDependenciesProvider';
|
|
19
21
|
export * from './context/InjectDependenciesProvider';
|
|
20
22
|
export { default as QueryClientProviderWithConfig } from './context/QueryClientProviderWithConfig';
|